path-to-regexp
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -0,1 +1,11 @@ | ||
1.2.0 / 2015-05-20 | ||
================== | ||
* Add support for matching an asterisk (`*`) as an unnamed match everything group (`(.*)`) | ||
1.1.1 / 2015-05-11 | ||
================== | ||
* Expose methods for working with path tokens | ||
1.1.0 / 2015-05-09 | ||
@@ -2,0 +12,0 @@ ================== |
11
index.js
@@ -24,5 +24,6 @@ var isarray = require('isarray') | ||
// | ||
// "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?"] | ||
// "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined] | ||
'([\\/.])?(?:\\:(\\w+)(?:\\(((?:\\\\.|[^)])*)\\))?|\\(((?:\\\\.|[^)])*)\\))([+*?])?' | ||
// "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?", undefined] | ||
// "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined, undefined] | ||
// "/*" => ["/", undefined, undefined, undefined, undefined, "*"] | ||
'([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^()])+)\\))?|\\(((?:\\\\.|[^()])+)\\))([+*?])?|(\\*))' | ||
].join('|'), 'g') | ||
@@ -67,2 +68,3 @@ | ||
var suffix = res[6] | ||
var asterisk = res[7] | ||
@@ -72,2 +74,3 @@ var repeat = suffix === '+' || suffix === '*' | ||
var delimiter = prefix || '/' | ||
var pattern = capture || group || (asterisk ? '.*' : '[^' + delimiter + ']+?') | ||
@@ -80,3 +83,3 @@ tokens.push({ | ||
repeat: repeat, | ||
pattern: escapeGroup(capture || group || '[^' + delimiter + ']+?') | ||
pattern: escapeGroup(pattern) | ||
}) | ||
@@ -83,0 +86,0 @@ } |
{ | ||
"name": "path-to-regexp", | ||
"description": "Express style path to RegExp utility", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"files": [ | ||
@@ -6,0 +6,0 @@ "index.js", |
@@ -132,2 +132,14 @@ # Path-to-RegExp | ||
#### Asterisk | ||
An asterisk can be used for matching everything. It is equivalent to an unnamed matching group of `(.*)`. | ||
```js | ||
var re = pathToRegexp('/foo/*', keys) | ||
// keys = [{ name: '0', ... }] | ||
re.exec('/foo/bar/baz') | ||
//=> ['/foo/bar/baz', 'bar/baz'] | ||
``` | ||
### Parse | ||
@@ -134,0 +146,0 @@ |
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
327
215
19127