-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(router-core): ensure rewrite basepath applies consistently #5202
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
base: main
Are you sure you want to change the base?
Changes from all commits
23be5f9
593cb78
508303a
2b831cf
a9dbeb7
b9a4ce3
e900a66
a161948
977587d
7f764e8
bcff760
9215441
8ad0f67
918e51e
a22766a
5f52ff8
710f5cc
e8757e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,10 +52,20 @@ export function Transitioner() { | |
_includeValidateSearch: true, | ||
}) | ||
|
||
if ( | ||
trimPathRight(router.latestLocation.href) !== | ||
trimPathRight(nextLocation.href) | ||
) { | ||
const latestPublicHref = trimPathRight(router.latestLocation.publicHref) | ||
const nextPublicHref = trimPathRight(nextLocation.publicHref) | ||
|
||
if (latestPublicHref !== nextPublicHref) { | ||
const latestOrigin = new URL(router.latestLocation.url).origin | ||
const nextOrigin = new URL(nextLocation.url).origin | ||
|
||
if (latestOrigin !== nextOrigin) { | ||
if (typeof window !== 'undefined') { | ||
window.location.href = nextLocation.url | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be more appropriate to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we could just call however, |
||
} | ||
return | ||
} | ||
|
||
router.commitLocation({ ...nextLocation, replace: true }) | ||
} | ||
|
||
|
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.
publicHref carries rewrite/basePath changes that should reflect in the browser URL
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.
what about the case when the rewrite changes the origin?
we would need to do a hard navigation here i think
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.
if we can get this solved, we can merge this
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.
Sorry for the late reply — I was on vacation.
Are there any cases where the origin can be changed through
basepath
orrewrite
?I think a bit more explanation would be helpful.
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.
yes you can for example map a path segment to a subdomain via a rewrite.
see this test for example
router/packages/react-router/tests/router.test.tsx
Line 2143 in e0c63d4