Skip to content
Myr

fix(router/trie-router): fix label with trailing wildcard pattern (#3892)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Taku Amano · committed by GitHub · parent 066c342 · Browse files · 3 files+18 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+18 added−1 removed

  • tests:+17 added−1 removed
  • other:+1 added−0 removed

3 files+18 added−1 removed

modified:src/router/linear-router/router.test.ts+4 added-1 removed
modified:src/router/trie-router/node.ts+1 added
148 unmodified lines
149 if (pattern === '*') {150 const astNode = node.#children['*']151 if (astNode) {152 handlerSets.push(...this.#getHandlerSets(astNode, method, node.#params))153 astNode.#params = params154 tempNodes.push(astNode)155 }156 continue157 }
46 unmodified lines
modified:src/router/common.case.test.ts+13 added
495 unmodified lines
496 expect(res[0].params['filename']).toEqual('chunk/nest/123.js')497 })498 })499500 describe('Capture regex pattern has trailing wildcard', () => {501 beforeEach(() => {502 router.add('GET', '/:dir{[a-z]+}/*/file.html', 'file.html')503 })504505 it('GET /foo/bar/file.html', () => {506 const res = match('GET', '/foo/bar/file.html')507 expect(res.length).toBe(1)508 expect(res[0].handler).toEqual('file.html')509 expect(res[0].params['dir']).toEqual('foo')510 })511 })512513 describe('non ascii characters', () => {514 beforeEach(() => {515 router.add('ALL', '/$/*', 'middleware $')516 router.add('GET', '/$/:name', 'get $ name')
280 unmodified lines