🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
Refactor site configuration update logic and improve ID validation
Bill Yang4b5fb3d21e85
diff --git a/server/src/api/sites/updateSitePrivateLinkConfig.ts b/server/src/api/sites/updateSitePrivateLinkConfig.tsindex 09b31ee13..609cfda33 100644--- a/server/src/api/sites/updateSitePrivateLinkConfig.ts+++ b/server/src/api/sites/updateSitePrivateLinkConfig.ts@@ -44,7 +44,7 @@ export async function updateSitePrivateLinkConfig(request: FastifyRequest, reply// Update the site config cacheif (action === "generate_private_link_key" || action === "revoke_private_link_key") {- siteConfig.updateConfig(parsedSiteId, { privateLinkKey: updateData.privateLinkKey });+ await siteConfig.updateConfig(parsedSiteId, { privateLinkKey: updateData.privateLinkKey });}return reply.send({diff --git a/server/src/lib/siteConfig.ts b/server/src/lib/siteConfig.tsindex d64650a74..55caf7595 100644--- a/server/src/lib/siteConfig.ts+++ b/server/src/lib/siteConfig.ts@@ -38,10 +38,11 @@ class SiteConfig {* Helper to determine if the input is a numeric siteId or string id*/private isNumericId(id: string | number): boolean {- if (String(id).length > 4) {- return false;+ if (typeof id === "number") {+ return Number.isInteger(id);}- return true;++ return /^\d+$/.test(id);}/**