Router matching multiple routes to controllers
- Vorherrschende Sprache
- JavaScript
- Sterne
- 1.6k
- Forks
- 179
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
I have the following routes defined:
``` javascript
exports.routes = function (map) {
map.all('admin/:controller/:action');
map.all('admin/:controller/:action/:id');
map.all(':controller/:action');
map.all(':controller/:action/:id');
};
```
When I visit /admin/mycontroller/index, I see in my console that compound is trying to access both:
```
Params: {"controller":"mycontroller","action":"index"} // this is correct
Params: {"controller":"admin","action":"mycontroller","id":"index"}
```
But I was expecting only the first to be routed. Is this a bug? Yes, both routes are valid, but only one is supposed to be executed, not every matching route.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Look at the router implementation in the compound framework, likely in a file like lib/router.js. The issue shows that multiple route patterns are being matched when only one should be. Start by understanding how the map.all method works and how route precedence is determined. Test by creating a simple app with the given routes and logging the matching logic to see why both are triggered.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, node.js
- Bereich
- api, backend
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 55/100