mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-16 15:32:19 +02:00
12 lines
275 B
TypeScript
12 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(".");
|
||
|
}
|