Skip to content

Instantly share code, notes, and snippets.

@prontiol
Created April 24, 2019 19:11
Show Gist options
  • Save prontiol/fe355a1266a1b488c50777f9b07f9f37 to your computer and use it in GitHub Desktop.
Save prontiol/fe355a1266a1b488c50777f9b07f9f37 to your computer and use it in GitHub Desktop.
getAbsoluteUrl
var getAbsoluteUrl = (function() {
var a;
return function(url) {
if(!a) a = document.createElement('a');
a.href = url;
return a.href;
};
})();
// Usage
getAbsoluteUrl('/something'); // https://davidwalsh.name/something
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment