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.

Create is-valid-domain.ts

Kiran K06af486e0b2b
diff --git a/apps/web/lib/api/domains/is-valid-domain.ts b/apps/web/lib/api/domains/is-valid-domain.ts
new file mode 100644
index 0000000000..68016df5a9
--- /dev/null
+++ b/apps/web/lib/api/domains/is-valid-domain.ts
@@ -0,0 +1,9 @@
+import { validDomainRegex } from "@dub/utils";
+
+export const isValidDomain = (domain: string) => {
+ return (
+ validDomainRegex.test(domain) &&
+ // make sure the domain doesn't contain dub.co/dub.sh/d.to
+ !/^(dub\.co|.*\.dub\.co|dub\.sh|.*\.dub\.sh|d\.to|.*\.d\.to)$/i.test(domain)
+ );
+};