@a11ywatch/core
Version:
a11ywatch central API
26 lines • 624 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getHostName = void 0;
const url_1 = require("url");
const getHostName = (url) => {
if (!url) {
return "";
}
let q = decodeURIComponent(url);
if (!/^(http|https)/.test(q)) {
if (q.startsWith("://")) {
q = `https${q}`;
}
else {
q = `https://${q}`;
}
}
try {
return new url_1.URL(q).hostname;
}
catch (e) {
console.error(`invalid url ${q} \n ${e}`);
}
};
exports.getHostName = getHostName;
//# sourceMappingURL=get-host.js.map
;