{"version":3,"file":"url.cjs","sources":["../../../src/utils/url.ts"],"sourcesContent":["const getDocumentBase = (): string | undefined =>\n  typeof document === 'undefined' ? undefined : document.baseURI;\n\n/**\n * Returns true when `url` resolves to an http(s) URL.\n *\n * Relative URLs are resolved against `base` (the document base URI in a\n * browser), so `/docs` passes while `javascript:`, `data:` and `mailto:` fail.\n * The URL parser lowercases the scheme, trims leading and trailing whitespace\n * and strips embedded tab/newline characters, so `JAVASCRIPT:`, ` javascript:`\n * and `java\\tscript:` variants are rejected too.\n */\nexport const isHttpUrl = (\n  url: string,\n  base: string | undefined = getDocumentBase()\n): boolean => {\n  try {\n    const { protocol } = new URL(url, base);\n    return protocol === 'http:' || protocol === 'https:';\n  } catch {\n    return false;\n  }\n};\n\n/**\n * Opens `url` in a new tab.\n *\n * `noopener` stops the new page from reaching back into this one through\n * `window.opener` (reverse tabnabbing). Browsers apply it implicitly for\n * `<a target=\"_blank\">` but not for `window.open`. Non-http(s) URLs are\n * refused with a warning, since a `javascript:` URL would otherwise run in\n * this document's origin.\n */\nexport const openInNewTab = (url: string): void => {\n  if (!isHttpUrl(url)) {\n    console.warn(`openInNewTab: refusing to open non-http(s) URL \"${url}\"`);\n    return;\n  }\n  window.open(url, '_blank', 'noopener');\n};\n"],"names":[],"mappings":";;;;AAAA,MAAM,kBAAkB,MACtB,OAAO,QAAA,KAAa,WAAA,GAAc,SAAY,QAAA,CAAS,OAAA;AAWlD,MAAM,SAAA,GAAY,CACvB,GAAA,EACA,IAAA,GAA2B,iBAAgB,KAC/B;AACZ,EAAA,IAAI;AACF,IAAA,MAAM,EAAE,QAAA,EAAS,GAAI,IAAI,GAAA,CAAI,KAAK,IAAI,CAAA;AACtC,IAAA,OAAO,QAAA,KAAa,WAAW,QAAA,KAAa,QAAA;AAAA,EAC9C,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF;AAWO,MAAM,YAAA,GAAe,CAAC,GAAA,KAAsB;AACjD,EAAA,IAAI,CAAC,SAAA,CAAU,GAAG,CAAA,EAAG;AACnB,IAAA,OAAA,CAAQ,IAAA,CAAK,CAAA,gDAAA,EAAmD,GAAG,CAAA,CAAA,CAAG,CAAA;AACtE,IAAA;AAAA,EACF;AACA,EAAA,MAAA,CAAO,IAAA,CAAK,GAAA,EAAK,QAAA,EAAU,UAAU,CAAA;AACvC;;;"}