history-browser
history-browser copied to clipboard
Fix/navigation with root
This is part of a patch for both aurelia-history-browser and aurelia-router and contains two bugfixes related to having root set to something else than /.
1. History could not handle outbound links
If root is set, eg., to /app1, the following link causes a routing error instead of navigating away from the app: < a href="/app2">Outbound link</a>.
This is fixed in 407959e.
2. History did not handle absolute paths within the app correctly
The router ignored root when creating URLs. This caused all non-default click actions (eg. CMD+Click, Right-click-> "Open in new Tab/Browser", etc.) to navigate to the wrong URL. (And broke links for crawlers.)
But as soon as the router creates correct URLs, history’s lack of proper root support causes all navigations to fail. This is fixed in bfad456.
@davismj Can you review this please?
If root is set, eg., to /app1, the following link causes a routing error instead of navigating away from the app: Outbound link.
I need to play around with this in a live application, specifically with push state and non push-state and make sure that the behaviors match. I'm guessing the assessment is correct but I do want to double check.
History did not handle absolute paths within the app correctly
I've recently made some changes that affect the way links are generated. I have a feeling this issue might be fixed.
Let me know if I can help you in any way. I’ve had my changes to router and history running in production in a push-state app (with root prefix) for a while without issues.
For outbound link, use < a href="/app2" router-ignore>Outbound link</a> to bypass router.
@huochunpeng Your suggestion would require me to annotate all links that might ever be part of any page, including user-added content. Breaking regular HTML is not an option.
I see. For user created content, I guess probably we can support something like this.
<div class="router-ignore">
<a></a>
</div>