path-to-regexp 0.1.6 → 0.1.7

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.

package/History.md CHANGED
@@ -1,3 +1,13 @@
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
+
1
11
  0.1.5 / 2015-05-08
2
12
  ==================
3
13
 
package/Readme.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Turn an Express-style path string such as `/user/:name` into a regular expression.
4
4
 
5
- **Note:** This is a legacy branch. You should upgrade to `1.x`. If you find you are stuck on this version, your code will need to take into account the `index` property on the keys.
5
+ **Note:** This is a legacy branch. You should upgrade to `1.x`.
6
6
 
7
7
  ## Usage
8
8
 
package/index.js CHANGED
@@ -91,7 +91,7 @@ function pathtoRegexp(path, keys, options) {
91
91
  var len = keys.length
92
92
 
93
93
  while (len-- > keysOffset && keys[len].offset > index) {
94
- keys[len].offset += 3;
94
+ keys[len].offset += 3; // Replacement length minus asterisk length.
95
95
  }
96
96
 
97
97
  return '(.*)';
@@ -99,6 +99,18 @@ function pathtoRegexp(path, keys, options) {
99
99
 
100
100
  // This is a workaround for handling unnamed matching groups.
101
101
  while (m = MATCHING_GROUP_REGEXP.exec(path)) {
102
+ var escapeCount = 0;
103
+ var index = m.index;
104
+
105
+ while (path.charAt(--index) === '\\') {
106
+ escapeCount++;
107
+ }
108
+
109
+ // It's possible to escape the bracket.
110
+ if (escapeCount % 2 === 1) {
111
+ continue;
112
+ }
113
+
102
114
  if (keysOffset + i === keys.length || keys[keysOffset + i].offset > m.index) {
103
115
  keys.splice(keysOffset + i, 0, {
104
116
  name: name++, // Unnamed matching groups must be consistently linear.
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.6",
4
+ "version": "0.1.7",
5
5
  "files": [
6
6
  "index.js",
7
7
  "LICENSE"