-
-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support options.replace
in hash router
#523
base: v3
Are you sure you want to change the base?
Conversation
|
? new HashChangeEvent("hashchange") | ||
: new Event("hashchange"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see that this event has also newURL
and oldURL
properties, maybe we should add them to the options?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah that's a good call 👍
const oldURL = new URL(window.location.href); | ||
const newURL = new URL(newRelativePath, window.location.origin); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that oldURL
and newURL
are actually strings according to the spec and they contain the full URL of the webpage including the new hash and everything else.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wondered why TS hadn't figure it out, but forgot it is a JS file 😬
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## v3 #523 +/- ##
========================================
- Coverage 0.17% 0.17% -0.01%
========================================
Files 10 10
Lines 578 580 +2
Branches 9 9
========================================
Hits 1 1
- Misses 568 570 +2
Partials 9 9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
const oldURL = window.location.href; | ||
const newURL = new URL(newRelativePath, window.location.origin).href; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to make it more consistent with the rest of the code
const oldURL = window.location.href; | |
const newURL = new URL(newRelativePath, window.location.origin).href; | |
const oldURL = location.href; | |
const newURL = new URL(newRelativePath, location.origin).href; |
This update adds support for path replacement in the hash router using options.replace, resolving the issue referenced in #522