find-my-way
Advanced tools
Comparing version 7.3.0 to 7.3.1
11
index.js
@@ -226,9 +226,14 @@ 'use strict' | ||
const charCode = path.charCodeAt(lastParamEndIndex) | ||
if (charCode === 58 || charCode === 47) { | ||
break | ||
const nextCharCode = path.charCodeAt(lastParamEndIndex + 1) | ||
if (charCode === 58 && nextCharCode === 58) { | ||
lastParamEndIndex++ | ||
continue | ||
} | ||
if (charCode === 58 || charCode === 47) break | ||
} | ||
const staticPart = path.slice(j, lastParamEndIndex) | ||
let staticPart = path.slice(j, lastParamEndIndex) | ||
if (staticPart) { | ||
staticPart = staticPart.split('::').join(':') | ||
staticPart = staticPart.split('%').join('%25') | ||
regexps.push(escapeRegExp(staticPart)) | ||
@@ -235,0 +240,0 @@ } |
{ | ||
"name": "find-my-way", | ||
"version": "7.3.0", | ||
"version": "7.3.1", | ||
"description": "Crazy fast http radix based router", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -206,2 +206,23 @@ 'use strict' | ||
test('Multi parametric route with colon separator', t => { | ||
t.plan(3) | ||
const findMyWay = FindMyWay({ | ||
defaultRoute: (req, res) => { | ||
t.fail('Should not be defaultRoute') | ||
} | ||
}) | ||
findMyWay.on('GET', '/:param(.*)::suffix', (req, res, params) => { | ||
t.equal(params.param, 'foo') | ||
}) | ||
findMyWay.on('GET', '/:param1(.*)::suffix1-:param2(.*)::suffix2/static', (req, res, params) => { | ||
t.equal(params.param1, 'foo') | ||
t.equal(params.param2, 'bar') | ||
}) | ||
findMyWay.lookup({ method: 'GET', url: '/foo:suffix', headers: {} }, null) | ||
findMyWay.lookup({ method: 'GET', url: '/foo:suffix1-bar:suffix2/static', headers: {} }, null) | ||
}) | ||
test('Multi parametric route with regexp / 2', t => { | ||
@@ -208,0 +229,0 @@ t.plan(8) |
@@ -100,2 +100,17 @@ 'use strict' | ||
test('Multi parametric route with encoded colon separator', t => { | ||
t.plan(1) | ||
const findMyWay = FindMyWay({ | ||
defaultRoute: (req, res) => { | ||
t.fail('Should not be defaultRoute') | ||
} | ||
}) | ||
findMyWay.on('GET', '/:param(.*)::suffix', (req, res, params) => { | ||
t.equal(params.param, 'foo-bar') | ||
}) | ||
findMyWay.lookup({ method: 'GET', url: '/foo-bar%3Asuffix', headers: {} }, null) | ||
}) | ||
function get (url) { | ||
@@ -102,0 +117,0 @@ return { method: 'GET', url, headers: {} } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
326032
8140