Last active
January 20, 2021 01:44
-
-
Save pinkhominid/37fbe30022ed622a9d0cc197a35505da to your computer and use it in GitHub Desktop.
Convert absolute URL to relative
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
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