Files
dashtab/app/utils/display-host.js
raucao 3909bd402a Show integration bylines as hostnames
The Manage screen reduces instance URLs to the hostname, and Home Assistant uses the integration name as its title with the instance name as byline.
2026-10-27 20:56:39 +04:00

17 lines
436 B
JavaScript

// Instance URLs are shown as bylines, where only the host identifies the
// instance. Keep the stored URL intact for network calls and reduce it to the
// hostname only for display.
export function displayHost(url) {
if (typeof url !== 'string' || !url) {
return '';
}
const value = /^[a-z][a-z0-9+.-]*:\/\//i.test(url) ? url : `https://${url}`;
try {
return new URL(value).hostname;
} catch {
return '';
}
}