UNPKG

zksync-sso

Version:
43 lines 1.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getWebsiteName = getWebsiteName; exports.getFavicon = getFavicon; exports.noThrow = noThrow; function getWebsiteName() { const fullTitle = document.title; if (!fullTitle) return null; const delimiters = [" - ", " | ", " : ", " · ", " — "]; for (const delimiter of delimiters) { const parts = fullTitle.split(delimiter); if (parts.length > 1) { return parts[0].trim(); } } return fullTitle.trim(); } function getFavicon() { const el = document.querySelector("link[sizes=\"192x192\"], link[sizes=\"180x180\"], link[rel=\"icon\"], link[rel=\"shortcut icon\"]"); const href = el?.getAttribute("href"); if (!href) return null; try { const url = new URL(href, document.location.href); if (url.protocol !== "https:" && url.protocol !== "http:") { return null; } return url.href; } catch { return null; } } function noThrow(fn) { try { return fn(); } catch { return null; } } //# sourceMappingURL=helpers.js.map