find-my-way
Advanced tools
Comparing version 7.0.0 to 7.0.1
11
index.js
@@ -277,5 +277,14 @@ 'use strict' | ||
const isRootWildcard = path === '*' || path === '/*' | ||
for (const existRoute of this._routesPatterns) { | ||
let samePath = false | ||
if (existRoute.path === path) { | ||
samePath = true | ||
} else if (isRootWildcard && (existRoute.path === '/*' || existRoute.path === '*')) { | ||
samePath = true | ||
} | ||
if ( | ||
existRoute.path === path && | ||
samePath && | ||
existRoute.method === method && | ||
@@ -282,0 +291,0 @@ deepEqual(existRoute.constraints, constraints) |
@@ -110,5 +110,3 @@ 'use strict' | ||
function buildRouteTree (mergedRouteArray, rootPath) { | ||
rootPath = rootPath || pathDelimiter | ||
function buildRouteTree (mergedRouteArray) { | ||
const result = [] | ||
@@ -115,0 +113,0 @@ const temp = { result } |
{ | ||
"name": "find-my-way", | ||
"version": "7.0.0", | ||
"version": "7.0.1", | ||
"description": "Crazy fast http radix based router", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -248,2 +248,28 @@ 'use strict' | ||
test('Method already declared if * is used', t => { | ||
t.plan(1) | ||
const findMyWay = FindMyWay() | ||
findMyWay.on('GET', '/*', () => {}) | ||
try { | ||
findMyWay.on('GET', '*', () => {}) | ||
t.fail('should throw error') | ||
} catch (e) { | ||
t.equal(e.message, 'Method \'GET\' already declared for route \'*\' with constraints \'{}\'') | ||
} | ||
}) | ||
test('Method already declared if /* is used', t => { | ||
t.plan(1) | ||
const findMyWay = FindMyWay() | ||
findMyWay.on('GET', '*', () => {}) | ||
try { | ||
findMyWay.on('GET', '/*', () => {}) | ||
t.fail('should throw error') | ||
} catch (e) { | ||
t.equal(e.message, 'Method \'GET\' already declared for route \'/*\' with constraints \'{}\'') | ||
} | ||
}) | ||
test('Method already declared [ignoreTrailingSlash=true]', t => { | ||
@@ -250,0 +276,0 @@ t.plan(2) |
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
313021
7870