Skip to content

Instantly share code, notes, and snippets.

@drzax
Created September 9, 2015 01:42
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 drzax/79f88ffcdbcdfae505d7 to your computer and use it in GitHub Desktop.
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
function qualifyURL(url) {
var a = document.createElement('a');
a.href = url;
return a.href;
}
@duongphuhiep
Copy link

new URL(relativeUrl, window.location.href).href

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment