mirror of
https://github.com/mendableai/firecrawl.git
synced 2025-12-02 01:52:28 +00:00
8 lines
244 B
TypeScript
8 lines
244 B
TypeScript
export function normalizeUrl(url: string) {
|
|
try {
|
|
const hostname = new URL(url).hostname;
|
|
return hostname.replace(/^www\./, "");
|
|
} catch (error) {
|
|
return url.replace(/^https?:\/\//, "").replace(/^www\./, "").split('/')[0];
|
|
}
|
|
} |