path-to-regexp
Advanced tools
Comparing version
@@ -296,14 +296,15 @@ /** | ||
return path; | ||
// Use a negative lookahead to match only capturing groups. | ||
var groups = path.source.match(/\((?!\?)/g); | ||
if (groups) { | ||
for (var i = 0; i < groups.length; i++) { | ||
keys.push({ | ||
name: i, | ||
prefix: "", | ||
suffix: "", | ||
modifier: "", | ||
pattern: "" | ||
}); | ||
} | ||
var groupsRegex = /\((?:\?<(.*?)>)?(?!\?)/g; | ||
var index = 0; | ||
var execResult = groupsRegex.exec(path.source); | ||
while (execResult) { | ||
keys.push({ | ||
// Use parenthesized substring match if available, index otherwise | ||
name: execResult[1] || index++, | ||
prefix: "", | ||
suffix: "", | ||
modifier: "", | ||
pattern: "" | ||
}); | ||
execResult = groupsRegex.exec(path.source); | ||
} | ||
@@ -310,0 +311,0 @@ return path; |
@@ -88,3 +88,3 @@ export interface ParseOptions { | ||
/** | ||
* When `true` the regexp allows an optional trailing delimiter to match. (default: `false`) | ||
* When `true` the regexp won't allow an optional trailing delimiter to match. (default: `false`) | ||
*/ | ||
@@ -91,0 +91,0 @@ strict?: boolean; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.pathToRegexp = exports.tokensToRegexp = exports.regexpToFunction = exports.match = exports.tokensToFunction = exports.compile = exports.parse = void 0; | ||
/** | ||
@@ -303,14 +304,15 @@ * Tokenize input string. | ||
return path; | ||
// Use a negative lookahead to match only capturing groups. | ||
var groups = path.source.match(/\((?!\?)/g); | ||
if (groups) { | ||
for (var i = 0; i < groups.length; i++) { | ||
keys.push({ | ||
name: i, | ||
prefix: "", | ||
suffix: "", | ||
modifier: "", | ||
pattern: "" | ||
}); | ||
} | ||
var groupsRegex = /\((?:\?<(.*?)>)?(?!\?)/g; | ||
var index = 0; | ||
var execResult = groupsRegex.exec(path.source); | ||
while (execResult) { | ||
keys.push({ | ||
// Use parenthesized substring match if available, index otherwise | ||
name: execResult[1] || index++, | ||
prefix: "", | ||
suffix: "", | ||
modifier: "", | ||
pattern: "" | ||
}); | ||
execResult = groupsRegex.exec(path.source); | ||
} | ||
@@ -317,0 +319,0 @@ return path; |
@@ -1,23 +0,25 @@ | ||
# 3.0.0 / 2019-01-13 | ||
# Moved to [GitHub Releases](https://github.com/pillarjs/path-to-regexp/releases) | ||
## 3.0.0 / 2019-01-13 | ||
- Always use prefix character as delimiter token, allowing any character to be a delimiter (e.g. `/:att1-:att2-:att3-:att4-:att5`) | ||
- Remove `partial` support, prefer escaping the prefix delimiter explicitly (e.g. `\\/(apple-)?icon-:res(\\d+).png`) | ||
# 2.4.0 / 2018-08-26 | ||
## 2.4.0 / 2018-08-26 | ||
- Support `start` option to disable anchoring from beginning of the string | ||
# 2.3.0 / 2018-08-20 | ||
## 2.3.0 / 2018-08-20 | ||
- Use `delimiter` when processing repeated matching groups (e.g. `foo/bar` has no prefix, but has a delimiter) | ||
# 2.2.1 / 2018-04-24 | ||
## 2.2.1 / 2018-04-24 | ||
- Allow empty string with `end: false` to match both relative and absolute paths | ||
# 2.2.0 / 2018-03-06 | ||
## 2.2.0 / 2018-03-06 | ||
- Pass `token` as second argument to `encode` option (e.g. `encode(value, token)`) | ||
# 2.1.0 / 2017-10-20 | ||
## 2.1.0 / 2017-10-20 | ||
@@ -27,3 +29,3 @@ - Handle non-ending paths where the final character is a delimiter | ||
# 2.0.0 / 2017-08-23 | ||
## 2.0.0 / 2017-08-23 | ||
@@ -39,7 +41,7 @@ - New option! Ability to set `endsWith` to match paths like `/test?query=string` up to the query string | ||
# 1.7.0 / 2016-11-08 | ||
## 1.7.0 / 2016-11-08 | ||
- Allow a `delimiter` option to be passed in with `tokensToRegExp` which will be used for "non-ending" token match situations | ||
# 1.6.0 / 2016-10-03 | ||
## 1.6.0 / 2016-10-03 | ||
@@ -50,15 +52,15 @@ - Populate `RegExp.keys` when using the `tokensToRegExp` method (making it consistent with the main export) | ||
# 1.5.3 / 2016-06-15 | ||
## 1.5.3 / 2016-06-15 | ||
- Add `\\` to the ignore character group to avoid backtracking on mismatched parens | ||
# 1.5.2 / 2016-06-15 | ||
## 1.5.2 / 2016-06-15 | ||
- Escape `\\` in string segments of regexp | ||
# 1.5.1 / 2016-06-08 | ||
## 1.5.1 / 2016-06-08 | ||
- Add `index.d.ts` to NPM package | ||
# 1.5.0 / 2016-05-20 | ||
## 1.5.0 / 2016-05-20 | ||
@@ -68,7 +70,7 @@ - Handle partial token segments (better) | ||
# 1.4.0 / 2016-05-18 | ||
## 1.4.0 / 2016-05-18 | ||
- Handle RegExp unions in path matching groups | ||
# 1.3.0 / 2016-05-08 | ||
## 1.3.0 / 2016-05-08 | ||
@@ -81,3 +83,3 @@ - Clarify README language and named parameter token support | ||
# 1.2.1 / 2015-08-17 | ||
## 1.2.1 / 2015-08-17 | ||
@@ -87,11 +89,11 @@ - Encode values before validation with path compilation function | ||
# 1.2.0 / 2015-05-20 | ||
## 1.2.0 / 2015-05-20 | ||
- Add support for matching an asterisk (`*`) as an unnamed match everything group (`(.*)`) | ||
# 1.1.1 / 2015-05-11 | ||
## 1.1.1 / 2015-05-11 | ||
- Expose methods for working with path tokens | ||
# 1.1.0 / 2015-05-09 | ||
## 1.1.0 / 2015-05-09 | ||
@@ -104,3 +106,3 @@ - Expose the parser implementation to consumers | ||
# 1.0.3 / 2015-01-17 | ||
## 1.0.3 / 2015-01-17 | ||
@@ -110,3 +112,3 @@ - Optimised function runtime | ||
# 1.0.2 / 2014-12-17 | ||
## 1.0.2 / 2014-12-17 | ||
@@ -118,15 +120,15 @@ - Use `Array.isArray` shim | ||
# 1.0.1 / 2014-08-27 | ||
## 1.0.1 / 2014-08-27 | ||
- Ensure installation works correctly on 0.8 | ||
# 1.0.0 / 2014-08-17 | ||
## 1.0.0 / 2014-08-17 | ||
- No more API changes | ||
# 0.2.5 / 2014-08-07 | ||
## 0.2.5 / 2014-08-07 | ||
- Allow keys parameter to be omitted | ||
# 0.2.4 / 2014-08-02 | ||
## 0.2.4 / 2014-08-02 | ||
@@ -137,7 +139,7 @@ - Code coverage badge | ||
# 0.2.3 / 2014-07-09 | ||
## 0.2.3 / 2014-07-09 | ||
- Add MIT license | ||
# 0.2.2 / 2014-07-06 | ||
## 0.2.2 / 2014-07-06 | ||
@@ -147,7 +149,7 @@ - A passed in trailing slash in non-strict mode will become optional | ||
# 0.2.1 / 2014-06-11 | ||
## 0.2.1 / 2014-06-11 | ||
- Fixed a major capturing group regexp regression | ||
# 0.2.0 / 2014-06-09 | ||
## 0.2.0 / 2014-06-09 | ||
@@ -164,7 +166,7 @@ - Improved support for arrays | ||
# 0.1.2 / 2014-03-10 | ||
## 0.1.2 / 2014-03-10 | ||
- Move testing dependencies to `devDependencies` | ||
# 0.1.1 / 2014-03-10 | ||
## 0.1.1 / 2014-03-10 | ||
@@ -174,9 +176,9 @@ - Match entire substring with `options.end` | ||
# 0.1.0 / 2014-03-06 | ||
## 0.1.0 / 2014-03-06 | ||
- Add `options.end` | ||
# 0.0.2 / 2013-02-10 | ||
## 0.0.2 / 2013-02-10 | ||
- Update to match current express | ||
- Add .license property to component.json |
{ | ||
"name": "path-to-regexp", | ||
"description": "Express style path to RegExp utility", | ||
"version": "6.1.0", | ||
"version": "6.2.0", | ||
"main": "dist/index.js", | ||
@@ -63,6 +63,3 @@ "typings": "dist/index.d.ts", | ||
"lint-staged": { | ||
"*.{js,jsx,ts,tsx,json,md,yml,yaml}": [ | ||
"npm run prettier", | ||
"git add" | ||
] | ||
"*.{js,jsx,ts,tsx,json,md,yml,yaml}": "npm run prettier" | ||
}, | ||
@@ -73,16 +70,19 @@ "publishConfig": { | ||
"devDependencies": { | ||
"@size-limit/preset-small-lib": "^2.1.6", | ||
"@types/jest": "^24.0.22", | ||
"@types/node": "^12.12.7", | ||
"husky": "^3.0.9", | ||
"jest": "^24.9.0", | ||
"lint-staged": "^9.4.2", | ||
"prettier": "^1.19.1", | ||
"@size-limit/preset-small-lib": "^4.5.6", | ||
"@types/jest": "^26.0.9", | ||
"@types/node": "^14.0.27", | ||
"@types/semver": "^7.3.1", | ||
"husky": "^4.2.5", | ||
"jest": "^26.2.2", | ||
"lint-staged": "^10.2.11", | ||
"prettier": "^2.0.5", | ||
"rimraf": "^3.0.0", | ||
"ts-jest": "^24.1.0", | ||
"tslint": "^5.20.1", | ||
"semver": "^7.3.2", | ||
"size-limit": "^4.5.6", | ||
"ts-jest": "^26.1.4", | ||
"tslint": "^6.1.3", | ||
"tslint-config-prettier": "^1.18.0", | ||
"tslint-config-standard": "^9.0.0", | ||
"typescript": "^3.7.2" | ||
"typescript": "^4.0.3" | ||
} | ||
} |
@@ -33,3 +33,3 @@ # Path-to-RegExp | ||
- **sensitive** When `true` the regexp will be case sensitive. (default: `false`) | ||
- **strict** When `true` the regexp allows an optional trailing delimiter to match. (default: `false`) | ||
- **strict** When `true` the regexp won't allow an optional trailing delimiter to match. (default: `false`) | ||
- **end** When `true` the regexp will match to the end of the string. (default: `true`) | ||
@@ -45,3 +45,3 @@ - **start** When `true` the regexp will match from the beginning of the string. (default: `true`) | ||
const regexp = pathToRegexp("/foo/:bar", keys); | ||
// regexp = /^\/foo\/([^\/]+?)\/?$/i | ||
// regexp = /^\/foo(?:\/([^\/#\?]+?))[\/#\?]?$/i | ||
// keys = [{ name: 'bar', prefix: '/', suffix: '', pattern: '[^\\/#\\?]+?', modifier: '' }] | ||
@@ -124,3 +124,3 @@ ``` | ||
Modifiers must be placed after the parameter (e.g. `/:foo?`, `/(test)?`, or `/:foo(test)?`). | ||
Modifiers must be placed after the parameter (e.g. `/:foo?`, `/(test)?`, `/:foo(test)?`, or `{-:foo(test)}?`). | ||
@@ -127,0 +127,0 @@ ##### Optional |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
0
-100%111238
-76.64%16
23.08%9
-35.71%931
-85.45%1
Infinity%