wzp
2021-05-13 7d694a9113118daec5be7ac224dab46a3b20f106
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
'use strict'
 
const t = require('tap')
const FindMyWay = require('../')
 
const noop = function () {}
 
t.test('issue-62', (t) => {
  t.plan(2)
 
  const findMyWay = FindMyWay({ allowUnsafeRegex: true })
 
  findMyWay.on('GET', '/foo/:id(([a-f0-9]{3},?)+)', noop)
 
  t.notOk(findMyWay.find('GET', '/foo/qwerty'))
  t.ok(findMyWay.find('GET', '/foo/bac,1ea'))
})
 
t.test('issue-62 - escape chars', (t) => {
  const findMyWay = FindMyWay()
 
  t.plan(2)
 
  findMyWay.get('/foo/:param(\\([a-f0-9]{3}\\))', noop)
 
  t.notOk(findMyWay.find('GET', '/foo/abc'))
  t.ok(findMyWay.find('GET', '/foo/(abc)'))
})