Skip to content

Instantly share code, notes, and snippets.

@john-yuan
Created January 6, 2019 06:33
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 john-yuan/b74adefb40c2030e5494880db71499f5 to your computer and use it in GitHub Desktop.
Save john-yuan/b74adefb40c2030e5494880db71499f5 to your computer and use it in GitHub Desktop.
Check whether the URL is absolute.
/**
* Check whether the URL is absolute
*
* @param {string} url - The URL to check
* @returns {boolean} - If the url is absolute return true, otherwise return false
*/
var isAbsoluteURL = function (url) {
return /^(?:[a-z][a-z0-9\-\.\+]*:)?\/\//i.test(url);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment