Skip to content

Instantly share code, notes, and snippets.

@nireno
Last active December 13, 2022 19:01
Show Gist options
  • Save nireno/b9f0f04c90003a3a712d14c2754eb574 to your computer and use it in GitHub Desktop.
Save nireno/b9f0f04c90003a3a712d14c2754eb574 to your computer and use it in GitHub Desktop.
Removes the authority (the scheme, hostname, and port) from a URL
function removeUrlAuthority(url) {
var urlObject = new URL(url);
var path = urlObject.pathname;
var query = urlObject.search;
var fragment = urlObject.hash;
return path + query + fragment;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment