mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-15 23:17:55 +02:00
11 lines
275 B
TypeScript
11 lines
275 B
TypeScript
export function extractBaseDomain(url: string): string {
|
|
const newUrl = new URL(url);
|
|
const hostname = newUrl.hostname;
|
|
const parts = hostname.split(".");
|
|
|
|
if (parts.length <= 2) {
|
|
return parts.join(".");
|
|
}
|
|
|
|
return parts.slice(1).join(".");
|
|
}
|