The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fix getLinkViaEdge + updateLink
Steven Tey427985e3caf4
diff --git a/apps/web/lib/api/links/update-link.ts b/apps/web/lib/api/links/update-link.tsindex f2970d959c..dbc233d692 100644--- a/apps/web/lib/api/links/update-link.ts+++ b/apps/web/lib/api/links/update-link.ts@@ -77,7 +77,7 @@ export async function updateLink({key,shortLink: linkConstructorSimple({domain: updatedLink.domain,- key: updatedLink.key,+ key,}),title: truncate(title, 120),description: truncate(description, 240),diff --git a/apps/web/lib/planetscale/get-link-via-edge.ts b/apps/web/lib/planetscale/get-link-via-edge.tsindex 41679385d5..c4750b8798 100644--- a/apps/web/lib/planetscale/get-link-via-edge.ts+++ b/apps/web/lib/planetscale/get-link-via-edge.ts@@ -1,7 +1,8 @@import { punyEncode } from "@dub/utils";import {decodeLinkIfCaseSensitive,- encodeKeyIfCaseSensitive,+ encodeKey,+ isCaseSensitiveDomain,} from "../api/case-sensitive-short-links";import { conn } from "./connection";import { EdgeLinkProps } from "./types";@@ -13,16 +14,18 @@ export const getLinkViaEdge = async ({domain: string;key: string;}) => {- const keyToQuery = encodeKeyIfCaseSensitive({- domain,- key,- });+ const keyToQuery = isCaseSensitiveDomain(domain)+ ? // for case sensitive domains, we need to encode the key+ encodeKey(key)+ : // for non-case sensitive domains, we need to make sure that the key is always URI-decoded + punycode-encoded+ // (cause that's how we store it in MySQL)+ punyEncode(decodeURIComponent(key));const { rows } =- (await conn.execute(- "SELECT * FROM Link WHERE domain = ? AND `key` = ?",- [domain, punyEncode(decodeURIComponent(keyToQuery))], // we need to make sure that the key is always URI-decoded + punycode-encoded (cause that's how we store it in MySQL)- )) || {};+ (await conn.execute("SELECT * FROM Link WHERE domain = ? AND `key` = ?", [+ domain,+ keyToQuery,+ ])) || {};const link =rows && Array.isArray(rows) && rows.length > 0