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.

improved regex for adding new links + added decodeURIComponent for link redirects

Steven Teyf8b4bda4ad3d
diff --git a/components/app/modals/add-edit-link-modal.tsx b/components/app/modals/add-edit-link-modal.tsx
index 5f31017314..60bde29c86 100644
--- a/components/app/modals/add-edit-link-modal.tsx
+++ b/components/app/modals/add-edit-link-modal.tsx
@@ -214,7 +214,7 @@ function AddEditLinkModal({
id="key"
required
autoFocus={false}
- pattern="[a-zA-Z0-9\-]+"
+ pattern="[\p{Letter}\p{Mark}-]+" // Unicode regex to match all languages (and omit all symbols except for dashes)
className={`${
keyExistsError
? "border-red-300 text-red-900 placeholder-red-300 focus:border-red-500 focus:ring-red-500"
diff --git a/lib/middleware/utils.ts b/lib/middleware/utils.ts
index ed3f40c8c0..3a59887d5d 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 = path.split("/")[1];
+ const key = decodeURIComponent(path.split("/")[1]); // to handle foreign languages like Hebrew :)
return { hostname, path, key };
};