Created
September 9, 2015 01:42
-
-
Save drzax/79f88ffcdbcdfae505d7 to your computer and use it in GitHub Desktop.
Qualify a URL in javascript. That is, convert a relative URL to an absolute URL
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
function qualifyURL(url) { | |
var a = document.createElement('a'); | |
a.href = url; | |
return a.href; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
new URL(relativeUrl, window.location.href).href