-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
fix(route-href): prefix the pathname for fragment hrefs #83
base: master
Are you sure you want to change the base?
Conversation
bee7fde
to
b0d1179
Compare
b0d1179
to
b0953f2
Compare
Would you mind taking a look @EisenbergEffect |
@davismj is our router lead. Matt, any thoughts on this? |
@@ -47,6 +47,11 @@ export class RouteHref { | |||
|
|||
let href = this.router.generate(this.route, this.params); | |||
|
|||
// Ensure fragments are created correctly | |||
if (href.startsWith('#') && window.location) { |
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.
Unfortunately, this approach will not make it in. Though in your case it does probably fix the issue, there are two key problems. First, and most importantly, we don't and can't depend on the window object as this can be run in node in a SSR scenario. Second, this code should be relegated to the this.router.generate
function.
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.
This is likely related to aurelia/router#451 or aurelia/router#252.
A PR that resolves this issue must:
- not depend on window, use the router.baseUrl instead
- have a consistent behavior with or without pushState
- have a consistent behavior with or without query parameters
- contain tests that verify the behavior works in both of the above scenarios for various urls
It seems when a
<base>
tag is used and a url contains something likeindex.html?some=query
then theroute-href
sets an incorrecthref
link.To reproduce:
http://run.plnkr.co/preview/<ID>/index.html?testing=true
url that is printed in a new tab.NEXT PAGE
and see the page force refresh back to#/next-page
then back toindex.html?testing=true#/home
This fix adds the windows pathname and search query before the href fragment so that it does not force a new page load.