The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
a small fix
Kiran Kc54554b268eb
diff --git a/apps/web/lib/api/case-sensitive-short-links.ts b/apps/web/lib/api/case-sensitive-short-links.tsindex 2df1509fa9..001782e732 100644--- a/apps/web/lib/api/case-sensitive-short-links.ts+++ b/apps/web/lib/api/case-sensitive-short-links.ts@@ -35,10 +35,12 @@ export const decodeKey = (hash: string): string => {.join("");};+// check if the domain is case sensitiveexport const isCaseSensitiveDomain = (domain: string) => {return CASE_SENSITIVE_DOMAINS.includes(domain);};+// encode the key if the domain is case sensitiveexport const encodeKeyIfCaseSensitive = ({domain,key,@@ -46,6 +48,7 @@ export const encodeKeyIfCaseSensitive = ({return isCaseSensitiveDomain(domain) ? encodeKey(key) : key;};+// decode the key if the domain is case sensitiveexport const decodeKeyIfCaseSensitive = ({domain,key,@@ -53,6 +56,7 @@ export const decodeKeyIfCaseSensitive = ({return isCaseSensitiveDomain(domain) ? decodeKey(key) : key;};+// decode the link if the domain is case sensitiveexport const decodeLinkIfCaseSensitive = (link: any) => {if (isCaseSensitiveDomain(link.domain)) {const originalKey = decodeKey(link.key);diff --git a/apps/web/lib/planetscale/get-link-via-edge.ts b/apps/web/lib/planetscale/get-link-via-edge.tsindex fc9f0a65be..fd4af1be4b 100644--- a/apps/web/lib/planetscale/get-link-via-edge.ts+++ b/apps/web/lib/planetscale/get-link-via-edge.ts@@ -7,7 +7,7 @@ import { conn } from "./connection";import { EdgeLinkProps } from "./types";export const getLinkViaEdge = async (domain: string, key: string) => {- key = decodeKeyIfCaseSensitive({+ const decodedKey = decodeKeyIfCaseSensitive({domain,key,});@@ -15,7 +15,7 @@ export const getLinkViaEdge = async (domain: string, key: string) => {const { rows } =(await conn.execute("SELECT * FROM Link WHERE domain = ? AND `key` = ?",- [domain, punyEncode(decodeURIComponent(key))], // we need to make sure that the key is always URI-decoded + punycode-encoded (cause that's how we store it in MySQL)+ [domain, punyEncode(decodeURIComponent(decodedKey))], // we need to make sure that the key is always URI-decoded + punycode-encoded (cause that's how we store it in MySQL))) || {};const link =