Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ module.exports = class Router extends EventEmitter {
all: method === 'ALL' || method === 'USE',
gettable: method === 'GET' || method === 'HEAD',
};
if(typeof route.path === 'string' && (route.path.includes(':') || route.path.includes('*') || (route.path.includes('(') && route.path.includes(')'))) && route.pattern instanceof RegExp) {
if(typeof route.path === 'string' && (route.path.includes(':') || route.path.includes('*') || (route.path.includes('(') && route.path.includes(')'))) && typeof route.pattern === 'object') {
route.complex = true;
}
routes.push(route);
Expand Down
13 changes: 6 additions & 7 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function removeDuplicateSlashes(path) {
}

function patternToRegex(pattern, isPrefix = false) {
if(pattern instanceof RegExp) {
if(typeof pattern === 'object') {
return pattern;
}
if(isPrefix && pattern === '') {
Expand All @@ -64,19 +64,18 @@ function patternToRegex(pattern, isPrefix = false) {
}

function needsConversionToRegex(pattern) {
if(pattern instanceof RegExp) {
if(pattern === '/*') {
return false;
}
if(pattern === '/*') {
if(typeof pattern === 'object') {
return false;
}

return pattern.includes('*') ||
return pattern.includes(':') ||
pattern.includes('*') ||
pattern.includes('?') ||
pattern.includes('+') ||
pattern.includes('(') ||
pattern.includes(')') ||
pattern.includes(':') ||
pattern.includes('{') ||
pattern.includes('}') ||
pattern.includes('[') ||
Expand All @@ -87,7 +86,7 @@ function canBeOptimized(pattern) {
if(pattern === '/*') {
return false;
}
if(pattern instanceof RegExp) {
if(typeof pattern === 'object') {
return false;
}
if(
Expand Down