Skip to content
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

Parametric regex match fails with similar routes #285

Closed
subhero24 opened this issue May 16, 2022 · 1 comment · Fixed by #291
Closed

Parametric regex match fails with similar routes #285

subhero24 opened this issue May 16, 2022 · 1 comment · Fixed by #291
Labels

Comments

@subhero24
Copy link
Contributor

Using two routes which start with a regex param, the second route which should match /b/static/ doesn't.

findMyWay.on('GET', '/:a(a)', () => {})
findMyWay.on('GET', '/:b(b)/static', () => {})

Here is a complete test:

'use strict'

const t = require('tap')
const test = t.test
const FindMyWay = require('../')

test('Parametric regex match with similar routes', (t) => {
  t.plan(1)
  const findMyWay = FindMyWay()

  findMyWay.on('GET', '/:a(a)', () => {})
  findMyWay.on('GET', '/:b(b)/static', () => {})

  t.same(findMyWay.find('GET', '/b/static', {}).params, { 'b': 'b' })
})
@ivan-tymoshenko
Copy link
Collaborator

@subhero24 I was wrong here #280 (comment). We can resolve it because there would always be only one matched route. The problem if we add multiple parametric route support is to check that /:a(a)/static and /:b(b)/static can't be registered at the same time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants