The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
dub.co/stats → dub.sh/stats
Steven Tey6fa3e1bbcaaa
diff --git a/apps/web/lib/middleware/utils/parse.ts b/apps/web/lib/middleware/utils/parse.tsindex 3d6db70540..0d92f413c3 100644--- a/apps/web/lib/middleware/utils/parse.ts+++ b/apps/web/lib/middleware/utils/parse.ts@@ -10,7 +10,7 @@ export const parse = (req: NextRequest) => {domain = SHORT_DOMAIN;}- // path is the path of the URL (e.g. dub.co/stats/github -> /stats/github)+ // path is the path of the URL (e.g. dub.sh/stats/github -> /stats/github)let path = req.nextUrl.pathname;// fullPath is the full URL path (along with search params)@@ -19,7 +19,7 @@ export const parse = (req: NextRequest) => {const fullPath = `${path}${searchParamsString}`;// Here, we are using decodeURIComponent to handle foreign languages like Hebrew- const key = decodeURIComponent(path.split("/")[1]); // key is the first part of the path (e.g. dub.co/stats/github -> stats)+ const key = decodeURIComponent(path.split("/")[1]); // key is the first part of the path (e.g. dub.sh/stats/github -> stats)const fullKey = decodeURIComponent(path.slice(1)); // fullKey is the full path without the first slash (to account for multi-level subpaths, e.g. d.to/github/repo -> github/repo)return { domain, path, fullPath, key, fullKey, searchParamsString };diff --git a/apps/web/ui/analytics/analytics-provider.tsx b/apps/web/ui/analytics/analytics-provider.tsxindex f5dd284d1f..b0a9f9c852 100644--- a/apps/web/ui/analytics/analytics-provider.tsx+++ b/apps/web/ui/analytics/analytics-provider.tsx@@ -137,7 +137,7 @@ export default function AnalyticsProvider({domain: domainSlug,};} else {- // Public stats page, e.g. dub.co/stats/github, stey.me/stats/weathergpt+ // Public stats page, e.g. dub.sh/stats/github, stey.me/stats/weathergptreturn {basePath: `/stats/${key}`,baseApiPath: `/api/analytics/edge`,diff --git a/apps/web/ui/analytics/index.tsx b/apps/web/ui/analytics/index.tsxindex a1f1eb6efa..8b5cccf0d0 100644--- a/apps/web/ui/analytics/index.tsx+++ b/apps/web/ui/analytics/index.tsx@@ -2,7 +2,7 @@/*This Analytics component lives in 2 different places:1. Workspace analytics page, e.g. app.dub.co/dub/analytics- 2. Public stats page, e.g. dub.co/stats/github, stey.me/stats/weathergpt+ 2. Public stats page, e.g. dub.sh/stats/github, stey.me/stats/weathergpt*/import AnalyticsProvider, { AnalyticsContext } from "./analytics-provider";