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.

update getApexDomain to handle deeplinks

Steven Tey8e217b1723a4
diff --git a/lib/utils.ts b/lib/utils.ts
index 31b3123ef6..06b62d6758 100644
--- a/lib/utils.ts
+++ b/lib/utils.ts
@@ -241,7 +241,9 @@ export const getSubdomain = (name: string, apexName: string) => {
export const getApexDomain = (url: string) => {
let domain;
try {
- domain = new URL(url).hostname;
+ // replace any custom scheme (e.g. notion://) with https://
+ // use the URL constructor to get the hostname
+ domain = new URL(url.replace(/^[a-zA-Z]+:\/\//, "https://")).hostname;
} catch (e) {
return "";
}