The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
simplify with regex
Steven Tey3037334816cf
diff --git a/components/app/modals/add-edit-domain-modal.tsx b/components/app/modals/add-edit-domain-modal.tsxindex 944b5cf392..e8763b3cb8 100644--- a/components/app/modals/add-edit-domain-modal.tsx+++ b/components/app/modals/add-edit-domain-modal.tsx@@ -211,6 +211,7 @@ function AddEditDomainModal({name="domain"id="domain"required+ autoFocusautoComplete="off"pattern="[[\p{Letter}\p{Mark}\d-.]+"className={`${diff --git a/lib/api/domains.ts b/lib/api/domains.tsindex 4ef10631fa..8a2ba64131 100644--- a/lib/api/domains.ts+++ b/lib/api/domains.ts@@ -12,10 +12,8 @@ export const validateDomain = async (}const validDomain =validDomainRegex.test(domain) &&- domain !== "dub.co" &&- !domain.endsWith(".dub.co") &&- domain !== "dub.sh" &&- !domain.endsWith(".dub.sh");+ // make sure the domain doesn't contain dub.co/dub.sh+ !/^(dub\.co|.*\.dub\.co|dub\.sh|.*\.dub\.sh)$/i.test(domain);if (!validDomain) {return "Invalid domain";