Last active
April 29, 2020 22:44
-
-
Save mnutt/ea88907b74b0e818eb62f57addfd6b6e to your computer and use it in GitHub Desktop.
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
function relativeHash(newUrl); | |
const currentUrl = new URL("http://somesite.com/index.html#/page/a"); // or just document.location | |
const newPath = new URL("../blog/b", `http://example.com${currentUrl.hash.slice(1)}`).pathname; | |
currentUrl.hash = `#${newPath}`; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment