The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fix the wildcard check
Kiran K0a04352ae041
diff --git a/apps/web/lib/analytics/verify-analytics-allowed-hostnames.ts b/apps/web/lib/analytics/verify-analytics-allowed-hostnames.tsindex 50a0d4b064..8e9abce617 100644--- a/apps/web/lib/analytics/verify-analytics-allowed-hostnames.ts+++ b/apps/web/lib/analytics/verify-analytics-allowed-hostnames.ts@@ -32,8 +32,8 @@ export const verifyAnalyticsAllowedHostnames = ({.map((domain) => domain.slice(2)); // Remove the "*.", leaving just the domainfor (const domain of wildcardMatches) {- // Check if the hostname ends with the domain and is not the root domain- if (hostname.endsWith(domain) && hostname !== domain) {+ // Allow only proper subdomains: ensure hostname ends with ".domain"+ if (hostname.endsWith(`.${domain}`)) {return true;}}diff --git a/apps/web/tests/misc/allowed-hostnames.test.ts b/apps/web/tests/misc/allowed-hostnames.test.tsindex 4b8374248a..4c41747dde 100644--- a/apps/web/tests/misc/allowed-hostnames.test.ts+++ b/apps/web/tests/misc/allowed-hostnames.test.ts@@ -47,6 +47,7 @@ describe("analytics allowed hostnames", () => {"https://otherdomain.com","https://blog.otherdomain.com","https://example.com.evil.com",+ "https://testexample.com",];testCases.forEach((referer) => {@@ -115,6 +116,7 @@ describe("analytics allowed hostnames", () => {"https://otherdomain.com","https://blog.otherdomain.com","https://example.com.evil.com",+ "https://testexample.com",];testCases.forEach((referer) => {