path-to-regexp 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of path-to-regexp might be problematic. Click here for more details.

Files changed (3) hide show
  1. package/index.js +8 -3
  2. package/package.json +1 -1
  3. package/History.md +0 -36
package/index.js CHANGED
@@ -7,7 +7,7 @@ module.exports = pathtoRegexp;
7
7
  /**
8
8
  * Match matching groups in a regular expression.
9
9
  */
10
- var MATCHING_GROUP_REGEXP = /\((?!\?)/g;
10
+ var MATCHING_GROUP_REGEXP = /\((?:\?<(.*?)>)?(?!\?)/g;
11
11
 
12
12
  /**
13
13
  * Normalize the given path string,
@@ -31,6 +31,7 @@ function pathtoRegexp(path, keys, options) {
31
31
  var strict = options.strict;
32
32
  var end = options.end !== false;
33
33
  var flags = options.sensitive ? '' : 'i';
34
+ var lookahead = options.lookahead !== false;
34
35
  var extraOffset = 0;
35
36
  var keysOffset = keys.length;
36
37
  var i = 0;
@@ -40,7 +41,7 @@ function pathtoRegexp(path, keys, options) {
40
41
  if (path instanceof RegExp) {
41
42
  while (m = MATCHING_GROUP_REGEXP.exec(path.source)) {
42
43
  keys.push({
43
- name: name++,
44
+ name: m[1] || name++,
44
45
  optional: false,
45
46
  offset: m.index
46
47
  });
@@ -123,7 +124,11 @@ function pathtoRegexp(path, keys, options) {
123
124
  }
124
125
 
125
126
  // If the path is non-ending, match until the end or a slash.
126
- path += (end ? '$' : (path[path.length - 1] === '/' ? '' : '(?=\\/|$)'));
127
+ if (end) {
128
+ path += '$';
129
+ } else if (path[path.length - 1] !== '/') {
130
+ path += lookahead ? '(?=\\/|$)' : '(?:\/|$)';
131
+ }
127
132
 
128
133
  return new RegExp(path, flags);
129
134
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "path-to-regexp",
3
3
  "description": "Express style path to RegExp utility",
4
- "version": "0.1.7",
4
+ "version": "0.1.9",
5
5
  "files": [
6
6
  "index.js",
7
7
  "LICENSE"
package/History.md DELETED
@@ -1,36 +0,0 @@
1
- 0.1.7 / 2015-07-28
2
- ==================
3
-
4
- * Fixed regression with escaped round brackets and matching groups.
5
-
6
- 0.1.6 / 2015-06-19
7
- ==================
8
-
9
- * Replace `index` feature by outputting all parameters, unnamed and named.
10
-
11
- 0.1.5 / 2015-05-08
12
- ==================
13
-
14
- * Add an index property for position in match result.
15
-
16
- 0.1.4 / 2015-03-05
17
- ==================
18
-
19
- * Add license information
20
-
21
- 0.1.3 / 2014-07-06
22
- ==================
23
-
24
- * Better array support
25
- * Improved support for trailing slash in non-ending mode
26
-
27
- 0.1.0 / 2014-03-06
28
- ==================
29
-
30
- * add options.end
31
-
32
- 0.0.2 / 2013-02-10
33
- ==================
34
-
35
- * Update to match current express
36
- * add .license property to component.json