Query string being is being treated as a path segment for route matching
See original GitHub issueI’m submitting a … (check one with “x”)
[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
Query string being is being treated as a path segment for route matching
RouterModule.forRoot([
{ path: 'items/all', component: AllItemsComponent }
{ path: 'items/:id/:alias', component: SingleItemComponent }
]);
- Navigating to
/items/all?param=x
shows AllItemsComponent - Navigating to
/items/all/?param=x
shows SingleItemComponent - Navigating to
/items/all/
redirects to/items/all
Expected/desired behavior
- Navigating to
/items/all?param=x
shows AllItemsComponent - Navigating to
/items/all/?param=x
shows AllItemsComponent or redirects to/items/all?param=x
It would be nice if we could provide a regex for matching routes, rather than just a simple path. This could be solved in the back-end but that is very annoying to have to do.
Reproduction of the problem
See above - sorry I don’t know how to demonstrate this using plnkr since it requires navigating directly to a page.
What is the expected behavior?
See above
What is the motivation / use case for changing the behavior?
If /path/
behaves the same as /path
, then /path/?query
should behave the same as /path?query
Please tell us about your environment:
- Angular version: 2.0.0-rc.5
- Browser: all
- Language: TypeScript 1.8
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Match route on querystring - Stack Overflow
You can use an inline constraint to specify the correct route to use. This is a working example [Route("api/[controller]")] public class ...
Read more >Query Parameters - Routing - Ember Guides
Query params allow for additional application state to be serialized into the URL ... This section describes how routing query parameters are used...
Read more >Routing and Action Selection in ASP.NET Web API
NET Web API routes an HTTP request to a particular action on a ... The framework tries to match the segments in the...
Read more >Cro::HTTP::Router
If a route matches on segments, but not on the HTTP method (for example, a PUT was performed, but the only routes matching...
Read more >Routing - hapi.dev
The route above responds to a GET request to / with the string Hello World! ... asking for that segment of the path...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Plunker would still be a complete runnable example that shows how you configured and connected stuff even when it doesn’t allow to reproduce the issue.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.