feat: navigate support data: protocol#534
Merged
molefrog merged 2 commits intomolefrog:v3from Nov 24, 2025
Merged
Conversation
|
|
molefrog
reviewed
Nov 21, 2025
Comment on lines
+29
to
+40
| if (location.protocol === "data:") { | ||
| const newHash = "#/" + to.replace(/^#?\/?/, ""); | ||
| newHistoryStatePath = newHash; | ||
| newURL = oldURL.split("#")[0] + newHash; | ||
| } else { | ||
| const [hash, search] = to.replace(/^#?\/?/, "").split("?"); | ||
| newHistoryStatePath = | ||
| location.pathname + | ||
| (search ? `?${search}` : location.search) + | ||
| `#/${hash}`; | ||
| newURL = new URL(newHistoryStatePath, location.origin).href; | ||
| } |
Owner
There was a problem hiding this comment.
Thank you for submitting this PR. I've got a theory that if we just change the URL constructor code, we will be able to fix this without handling a special case when the protocol is :data
Something like:
const [hash, search] = to.replace(/^#?\/?/, "").split("?");
const newRelativePath =
location.pathname + (search ? `?${search}` : location.search) + `#/${hash}`;
const oldURL = location.href;
// Works for ALL protocols including data:
const url = new URL(location.href);
url.hash = `/${hash}`;
if (search) url.search = search;
const newURL = url.href;Could you please check if this is something we could use?
Owner
There was a problem hiding this comment.
Actually, nevermind. I'm going to merge this and refactor separately. Thanks!
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#533