-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
Opening url in new tab results in error when the config.options.root is set #457
Comments
I am having the exact same problem. As a note, it happens only when |
Just checking, did you put a |
Yes, it is there <base href="/some-root/"> I have just checked again that both However, the |
The longer I think about it the more convinced I am that the problem would be solved if the router generated links without the leading slash. This applies to navigation items, |
Any news about this? I'm using server-side rendering and this bug breaks all links for robots. Also users cannot use middle-click or open in a new tab. |
Hi there! I wonder if this behavior is hard to change or you just do not consider this as important flaw? Also, I don't think that the Thank you! |
Temporary (I hope) fix for this issue: with support of arrive.js you can watch for new links with import {RouterConfiguration} from "aurelia-router";
// temporary fix for https://github.com/aurelia/router/issues/457
export function supportMiddleClickInLinks(config: RouterConfiguration) {
const addBaseUrlIfMiddleClick = (event: JQueryEventObject) => {
if (event.ctrlKey || event.which == 2) {
const link = $(event.currentTarget);
const originalHref = link.attr('href');
link.attr('href', config.options.root + originalHref);
setTimeout(() => link.attr('href', originalHref));
}
};
$(document).arrive("a[route-href]", function (newLink) {
$(newLink).mouseup(addBaseUrlIfMiddleClick);
});
} Initialize it in your configureRouter(config: RouterConfiguration, router: Router) {
// ...
config.options.root = '/some-root';
supportMiddleClickInLinks(config);
} |
@fracz - Thank you for posting this fix. This issue has been a severe pain, but your idea is working great. |
Our users just reported that right click -> open in new tab still does not work. Have no idea how to workaround this... |
@fracz can you point me to a working example? |
Cannot create such example in Gist.run, because it's difficult to demonstrate URL roots there. However, I have extended the ScottWhittaker's Aurelia Router Demo by adding the following lines to the
See updated Gist: https://gist.github.com/fracz/92d3472cfb39c7233c6cc4fb031a4183 Try opening the links there in new tab. Thank you for investigating this! |
@davismj any progress with this issue? Thank you! |
Any progress on this issue? |
I'm submitting a bug report
1.1.1
Current behavior:
When router is configured with root path, e.g.
Then the following link correctly instructs aurelia-router to open
/some-root/some-page
:However, when the link is clicked with middle mouse button (open in new tab), it opens new tab with
/some-page
url instead of/some-root/some-page
.When I include the root path in the link
then aurelia tells me there is no such route and redirects to
/some-root/some-root/some-page
but middle-button click works.Expected/desired behavior:
Aurelia should accept links with root inside href and ignore it. The
href
of navigation items fromrouter.navigation
should also contain the root path.The text was updated successfully, but these errors were encountered: