path-to-regexp
Advanced tools
Comparing version 3.2.0 to 3.3.0
13
index.js
@@ -93,2 +93,3 @@ /** | ||
var delimiter = prev || defaultDelimiter | ||
var prevText = prev || (typeof tokens[tokens.length - 1] === 'string' ? tokens[tokens.length - 1] : '') | ||
@@ -103,3 +104,3 @@ tokens.push({ | ||
? escapeGroup(pattern) | ||
: '[^' + escapeString(delimiter === defaultDelimiter ? delimiter : (delimiter + defaultDelimiter)) + ']+?' | ||
: restrictBacktrack(delimiter, defaultDelimiter, prevText) | ||
}) | ||
@@ -116,2 +117,12 @@ } | ||
function restrictBacktrack (delimiter, defaultDelimiter, prevText) { | ||
var charGroup = '[^' + escapeString(delimiter === defaultDelimiter ? delimiter : (delimiter + defaultDelimiter)) + ']' | ||
if (!prevText || prevText.indexOf(delimiter) > -1 || prevText.indexOf(defaultDelimiter) > -1) { | ||
return charGroup + '+?' | ||
} | ||
return escapeString(prevText) + '|(?:(?!' + escapeString(prevText) + ')' + charGroup + ')+?' | ||
} | ||
/** | ||
@@ -118,0 +129,0 @@ * Compile a string to a template function for the path. |
{ | ||
"name": "path-to-regexp", | ||
"description": "Express style path to RegExp utility", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "typings": "index.d.ts", |
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
458
25834
5