This commit is contained in:
heiye111
2025-09-20 21:06:53 +08:00
commit c74f28caa7
2539 changed files with 365006 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
'use strict'
const { test } = require('node:test')
const FindMyWay = require('../')
test('contain param and wildcard together', t => {
t.plan(4)
const findMyWay = FindMyWay({
defaultRoute: (req, res) => {
t.assert.fail('we should not be here, the url is: ' + req.url)
}
})
findMyWay.on('GET', '/:lang/item/:id', (req, res, params) => {
t.assert.deepEqual(params.lang, 'fr')
t.assert.deepEqual(params.id, '12345')
})
findMyWay.on('GET', '/:lang/item/*', (req, res, params) => {
t.assert.deepEqual(params.lang, 'fr')
t.assert.deepEqual(params['*'], '12345/edit')
})
findMyWay.lookup(
{ method: 'GET', url: '/fr/item/12345', headers: {} },
null
)
findMyWay.lookup(
{ method: 'GET', url: '/fr/item/12345/edit', headers: {} },
null
)
})