Skip to content

Instantly share code, notes, and snippets.

@pinkhominid
Last active January 20, 2021 01:44
Show Gist options
  • Save pinkhominid/37fbe30022ed622a9d0cc197a35505da to your computer and use it in GitHub Desktop.
Save pinkhominid/37fbe30022ed622a9d0cc197a35505da to your computer and use it in GitHub Desktop.
Convert absolute URL to relative
export function urlToRelative(abs) {
const url = new URL(abs);
const rel = url.toString().substring(url.origin.length);
return rel;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment