-
Notifications
You must be signed in to change notification settings - Fork 66
-
Notifications
You must be signed in to change notification settings - Fork 66
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
Counterintuitive behavior with trailing slashes in patterns #37
Comments
For now I'm explaining the existing behavior in the article and commenting that this is something that we're actively considering. |
Ran into this, and also the inverse - if you don't have a trailing slash on the URL, the carbon-route with a leading slash in the pattern won't match it. Agreed - for now it's a good thing to make sure to call out in the documentation. |
As this is an API feedback bug I'd love to hear more from folks who are running into this. Anyone running into this? If so, was it something you noticed and got past quickly or did it leave you scratching your head for a while. Let us know! |
While not specifically trailing slashes, I am currently having issues with matching the root directory. My setup is as follows: <carbon-location route="{{route}}"></carbon-location>
<carbon-route route="{{route}}" pattern="/:page" data="{{routeData}}"></carbon-route>
<iron-lazy-pages selected="{{routeData.page}}" attr-for-selected="data-route">
<template is="iron-lazy-page" data-route="">
Home
<a href="/store">Visit the store.</a>
</template>
<template is="iron-lazy-page" data-route="store" path="store-page/store-page.html">
This is the store page.
<a href="/">Head back home.</a>
</template>
</iron-lazy-pages> Sadly this is not working, because Object {prefix: "", path: "/", __queryParams: Object} whereas Object {page: null} What I would expect (and to make a home-page routing work) is that the |
EDIT2: Sigh it was a problem with |
I already gave an example in the linked issue #75, but currently it is not possible to navigate from a parent route (i.e. domain.com/users) to a subroute (i.e. domain/users/1) purely with databinding, because of the missing trailing slash. |
Im running into same issue that @timeu mentioned. |
As referenced above I raised this in issue #123. The real problem is not, to my mind related to trailing slashes or not, it is that fact that stale data is left in tail. I have several layers of iron-pages selecting between different things, and at each layer down the hierarchy I really want route.page to be passed to my lazy loading behaviour such that I can go the I have found the best way for deep down layers of my application to jump to a new path is to include an iron location element and a 'path' property. If I then do Unfortunately to make this work the way it is currently set up means I have to use these strange '/reports/menu' which get echoed to the browser location bar. I doesn't matter too much to the application (as long as I know the default) but isn't really what I want to show my user. I haven't got as far as trying to handle something like referenced in #75, but the principal will be the same. Instead of /user being a user selection page and /user/4 being the page showing the details of user 4, I would have to invent a url like /user/0 to support the page selection with iron-pages. Not something that makes sense to me. |
@akc42 I am having the exact same issue: stale paths are left over in the route's tail because there is no match without the trailing slash... |
As @rictic asked, I'm about two hours already trying to figure out how to deal with the differences between
That's because The first one, that I am using throughout the app, doesn't work, because the router never gets active. I don't know what to do anymore. |
I've a similar issue: I want to make Only option that I could find so far:
|
For anyone searching for a quick fix, I hope this helps: https://jsbin.com/meduqu/20/edit?html,output. Lines 17 and 47 are the main things to look at. Line 17:
Line 47:
|
The problem with @NeverOddOrEven's solution is that it breaks the back button. The user will now have to press back twice. |
I've managed to compile a good, from my perspective anyway, solution to this problem. The trick is to leverage the active property combined with the data one. The problemRoutesWe have two levels of routing that configure the following possible urls:
Trailing slashes must be dealt with in the same way as no trailing slashes ( Where The solutionThe 404 fallback is omitted from this example for the sake of simplicity. ElementsAll visible pages are controlled using An
|
A trailing slash in a pattern currently means that you want to match a slash followed by the empty string.
This is counterintuitive, and an easy place to make mistakes. However, it's also useful, for specifically matching paths that end with a trailing slash.
The text was updated successfully, but these errors were encountered: