The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
code improvements
Pedro Ladeira592279370be6
diff --git a/apps/web/lib/analytics/filter-helpers.ts b/apps/web/lib/analytics/filter-helpers.tsindex 9ed23f9610..2cb312e9d1 100644--- a/apps/web/lib/analytics/filter-helpers.ts+++ b/apps/web/lib/analytics/filter-helpers.ts@@ -186,6 +186,10 @@ export function hasExactlyOneLinkIdFilter(linkId: string | ParsedFilter | undefined,): boolean {if (!linkId) return false;- if (typeof linkId === "string") return true;- return linkId.sqlOperator === "IN" && linkId.values.length === 1;+ if (typeof linkId === "string") return linkId.length > 0;+ return (+ linkId.sqlOperator === "IN" &&+ linkId.values.length === 1 &&+ linkId.values[0].length > 0+ );}diff --git a/apps/web/tests/analytics/advanced-filter-helpers.test.ts b/apps/web/tests/analytics/advanced-filter-helpers.test.tsindex c1d6bf454c..90134467c9 100644--- a/apps/web/tests/analytics/advanced-filter-helpers.test.ts+++ b/apps/web/tests/analytics/advanced-filter-helpers.test.ts@@ -641,5 +641,19 @@ describe("Advanced Filters - Unit Tests", () => {}),).toBe(false);});++ test("returns false for an empty string link id", () => {+ expect(hasExactlyOneLinkIdFilter("")).toBe(false);+ });++ test("returns false for a single empty included link id", () => {+ expect(+ hasExactlyOneLinkIdFilter({+ operator: "IS",+ sqlOperator: "IN",+ values: [""],+ }),+ ).toBe(false);+ });});});