What's the fastest method to detect if foo='http://john.doe'
is an external url (in comparsion to window.location.href
)?
To find external links to your website, you'll need to use an SEO tool such as Google Search Console or Moz's Link Explorer. These indexes can show you known backlinks to your site, along with other information such as the anchor text used.
External links are a hyperlinks that point at (target) any domain other than the domain the link exists on (source). External links have a greater impact on search engine rankings than internal links because they are valued by search engines as external votes of confidence/popularity in a web page.
Overview. An external link is a link that goes to any website outside of Cascade Server. In other words, any website that does not start with "www.csueastbay.edu". Examples of external links include: Google, East Bay Today, and Microsoft.
If you consider a URL being external if either the scheme, host or port is different, you could do something like this:
function isExternal(url) { var match = url.match(/^([^:\/?#]+:)?(?:\/\/([^\/?#]*))?([^?#]+)?(\?[^#]*)?(#.*)?/); if (typeof match[1] === "string" && match[1].length > 0 && match[1].toLowerCase() !== location.protocol) return true; if (typeof match[2] === "string" && match[2].length > 0 && match[2].replace(new RegExp(":("+{"http:":80,"https:":443}[location.protocol]+")?$"), "") !== location.host) return true; return false; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With