Created
January 6, 2019 06:33
-
-
Save john-yuan/b74adefb40c2030e5494880db71499f5 to your computer and use it in GitHub Desktop.
Check whether the URL is absolute.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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