pinafore/src/routes/_utils/urlIsCrossOrigin.js
2019-08-11 11:09:51 -07:00

8 lines
205 B
JavaScript

export function urlIsCrossOrigin (href) {
try {
return new URL(href, location.href).origin !== location.origin
} catch (e) {
console.error('Ignoring malformed URL', href)
return true
}
}