Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

ensure 'www.' is only removed at the start of domain

Michael Kreuzmayrfc28a001dc57
diff --git a/apps/web/lib/middleware/utils/parse.ts b/apps/web/lib/middleware/utils/parse.ts
index 0d92f413c3..ec38d342a7 100644
--- a/apps/web/lib/middleware/utils/parse.ts
+++ b/apps/web/lib/middleware/utils/parse.ts
@@ -4,7 +4,7 @@ import { NextRequest } from "next/server";
export const parse = (req: NextRequest) => {
let domain = req.headers.get("host") as string;
// remove www. from domain and convert to lowercase
- domain = domain.replace("www.", "").toLowerCase();
+ domain = domain.replace(/^www./, "").toLowerCase();
if (domain === "dub.localhost:8888" || domain.endsWith(".vercel.app")) {
// for local development and preview URLs
domain = SHORT_DOMAIN;