umami/lib/url.js

12 lines
241 B
JavaScript
Raw Normal View History

export function removeTrailingSlash(url) {
2020-09-01 05:25:31 +02:00
return url && url.length > 1 && url.endsWith('/') ? url.slice(0, -1) : url;
}
export function getDomainName(str) {
try {
return new URL(str).hostname;
2020-09-01 05:25:31 +02:00
} catch (e) {
return str;
}
}