SHARE
TWEET

Untitled

a guest Jul 23rd, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function isInternalLink(href) {
  2.     try {
  3.         /* full URL i.e. has protocol */
  4.         let url = new URL(href)
  5.         return url.origin === window.location.origin
  6.     } catch {
  7.         return !href.startsWith('//') ||
  8.             (href.startsWith('//') && (window.location.protocol + href).startsWith(window.location.origin))
  9.     }
  10. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top