question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Query string being is being treated as a path segment for route matching

See original GitHub issue

I’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:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
zoechicommented, Sep 6, 2016

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.

0reactions
angular-automatic-lock-bot[bot]commented, Jun 21, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found