The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
added decodeURIComponent for all edge api routes
Steven Teya0c2a469bae5
diff --git a/lib/middleware/utils.ts b/lib/middleware/utils.tsindex 3a59887d5d..b277b4e32a 100644--- a/lib/middleware/utils.ts+++ b/lib/middleware/utils.ts@@ -5,7 +5,7 @@ export const parse = (req: NextRequest) => {let hostname = req.headers.get("host");if (HOME_HOSTNAMES.has(hostname)) hostname = "dub.sh";const path = req.nextUrl.pathname;- const key = decodeURIComponent(path.split("/")[1]); // to handle foreign languages like Hebrew :)+ const key = decodeURIComponent(path.split("/")[1]); // to handle foreign languages like Hebrewreturn { hostname, path, key };};diff --git a/pages/api/edge/links/[key]/clicks.ts b/pages/api/edge/links/[key]/clicks.tsindex 336c533041..f6d1d1bcb9 100644--- a/pages/api/edge/links/[key]/clicks.ts+++ b/pages/api/edge/links/[key]/clicks.ts@@ -8,7 +8,7 @@ export const config = {export default async function handler(req: NextRequest) {if (req.method === "GET") {const url = req.nextUrl.pathname;- const key = url.split("/")[4];+ const key = decodeURIComponent(url.split("/")[4]);const response = await getLinkClicksCount("dub.sh", key);return new Response(JSON.stringify(response), { status: 200 });} else {diff --git a/pages/api/edge/links/[key]/exists.ts b/pages/api/edge/links/[key]/exists.tsindex 979352b512..4dd89f6415 100644--- a/pages/api/edge/links/[key]/exists.ts+++ b/pages/api/edge/links/[key]/exists.ts@@ -8,7 +8,7 @@ export const config = {export default async function handler(req: NextRequest) {if (req.method === "GET") {const url = req.nextUrl.pathname;- const key = url.split("/")[4];+ const key = decodeURIComponent(url.split("/")[4]);const response = await checkIfKeyExists("dub.sh", key);return new Response(JSON.stringify(response), { status: 200 });} else {diff --git a/pages/api/edge/links/[key]/stats.ts b/pages/api/edge/links/[key]/stats.tsindex a910809fce..b04fcd272d 100644--- a/pages/api/edge/links/[key]/stats.ts+++ b/pages/api/edge/links/[key]/stats.ts@@ -14,7 +14,7 @@ export const config = {export default async function handler(req: NextRequest) {if (req.method === "GET") {const url = req.nextUrl.pathname;- const key = url.split("/")[4];+ const key = decodeURIComponent(url.split("/")[4]);const interval = req.nextUrl.searchParams.get("interval") as| IntervalProps| undefined;