Skip to content

Instantly share code, notes, and snippets.

@whizkydee
Created October 27, 2020 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whizkydee/6fd8e08b53f8dcdcf750d883fe4448c1 to your computer and use it in GitHub Desktop.
Save whizkydee/6fd8e08b53f8dcdcf750d883fe4448c1 to your computer and use it in GitHub Desktop.
export function isWithinOrigin(url: any, origin: string) {
try {
const {origin: derivedOrigin} = new URL(url);
if (derivedOrigin === origin) {
return true;
}
return false;
} catch {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment