1
0
mirror of https://github.com/kremalicious/umami.git synced 2024-12-23 01:30:05 +01:00
umami/lib/url.js
2020-09-15 21:25:51 -07:00

16 lines
356 B
JavaScript

export function removeTrailingSlash(url) {
return url && url.length > 1 && url.endsWith('/') ? url.slice(0, -1) : url;
}
export function removeWWW(url) {
return url && url.length > 1 && url.startsWith('www.') ? url.slice(4) : url;
}
export function getDomainName(str) {
try {
return new URL(str).hostname;
} catch (e) {
return str;
}
}