Comments (5)
It may be that your /33
is static? And that has precedence?
from find-my-way.
That appears to be it.
function notFoundHandler () {}
function handler (req, res, params) {
console.log(params)
}
const FindMyWay = require('find-my-way')
const a = new FindMyWay({ defaultRoute: notFoundHandler })
a.on('GET', '/:userId/foo/bar', handler)
a.on('GET', '/33/:a(^.*$)/:b', handler)
a.lookup({ url: '/33/foo/bar', method: 'GET', headers: {} }, () => {})
// { a: 'foo', b: 'bar' }
const b = new FindMyWay({ defaultRoute: notFoundHandler })
b.on('GET', '/foo/bar/:userId', handler)
b.on('GET', '/:a(^.*$)/:b/33', handler)
b.lookup({ url: '/foo/bar/33', method: 'GET', headers: {} }, () => {})
// { userId: '33' }
It probably tries to take "the most static route" possible.
from find-my-way.
yes that’s it. If the doc is unclear, would you mind sending a PR?
from find-my-way.
Thanks, I'll
from find-my-way.
This behavior is correct, we are matching every chunk between the slashes in order.
In particular the parametric routes go before the parametric ones with regexp.
This is true, but we run the check for every node in the current level and not the entire route.
from find-my-way.
Related Issues (20)
- Route-Exclusive Custom Constraint Strategy HOT 4
- how to get matched route path HOT 4
- Broken parsing of route with multiple params within the same couple of slash HOT 10
- Pretty print should use internal trees for debuging
- Pretty print should show all params names or doesn't show any of them
- Allow users to have an additional regex node HOT 10
- improve removeDuplicateSlashes HOT 1
- url-sanitizer, thoughts on lookups? HOT 3
- ContraintStrategy in typescript declaration contains a validate function HOT 5
- Exclude test/ from package distribution
- Get Test Coverage to 100% HOT 6
- Add `has` method HOT 1
- feat: expose `params` inside `findRoute` HOT 2
- Host constraint breaks with 32 handlers HOT 1
- Incompatibility with Cloudflare due to using assert instead of node:assert HOT 3
- Decoding of %2F HOT 2
- route with params and open/close paren
- Bug - parameter separator logic bug when path end with variable params HOT 1
- Potential performance improvements HOT 8
- Resolving "Error: Wildcard must be the last character in the route" HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from find-my-way.