history-browser icon indicating copy to clipboard operation
history-browser copied to clipboard

Fix/navigation with root

Open rluba opened this issue 7 years ago • 7 comments

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.

rluba avatar Jun 01 '18 15:06 rluba

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jun 01 '18 15:06 CLAassistant

@davismj Can you review this please?

EisenbergEffect avatar Jun 13 '18 04:06 EisenbergEffect

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.

davismj avatar Aug 01 '18 04:08 davismj

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.

rluba avatar Aug 18 '18 18:08 rluba

For outbound link, use < a href="/app2" router-ignore>Outbound link</a> to bypass router.

3cp avatar Jan 08 '19 02:01 3cp

@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.

rluba avatar Jan 08 '19 08:01 rluba

I see. For user created content, I guess probably we can support something like this.

<div class="router-ignore">
  <a></a>
</div>

3cp avatar Jan 08 '19 08:01 3cp