Skip to content

Commit

Permalink
Fix issue #280 (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
subhero24 authored May 15, 2022
1 parent 2985fbd commit 455e3ba
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 1 addition & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,9 +458,7 @@ Router.prototype.find = function find (method, path, derivedConstraints) {

if (currentNode.isRegex) {
const matchedParameters = currentNode.regex.exec(decoded)
if (matchedParameters === null) {
return null
}
if (matchedParameters === null) continue

for (let i = 1; i < matchedParameters.length; i++) {
const param = matchedParameters[i]
Expand Down
15 changes: 15 additions & 0 deletions test/issue-280.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict'

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

test('Wildcard route match when regexp route fails', (t) => {
t.plan(1)
const findMyWay = FindMyWay()

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

t.same(findMyWay.find('GET', '/b', {}).params, { '*': 'b' })
})

0 comments on commit 455e3ba

Please sign in to comment.