path-to-regexp 2.3.0 → 2.4.0

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.
package/History.md CHANGED
@@ -1,3 +1,8 @@
1
+ 2.3.0 / 2018-08-20
2
+ ==================
3
+
4
+ * Use `delimiter` when processing repeated matching groups (e.g. `foo/bar` has no prefix, but has a delimiter)
5
+
1
6
  2.2.1 / 2018-04-24
2
7
  ==================
3
8
 
package/Readme.md CHANGED
@@ -30,7 +30,8 @@ var pathToRegexp = require('path-to-regexp')
30
30
  - **options**
31
31
  - **sensitive** When `true` the regexp will be case sensitive. (default: `false`)
32
32
  - **strict** When `true` the regexp allows an optional trailing delimiter to match. (default: `false`)
33
- - **end** When `false` the regexp will match the beginning instead of the entire string. (default: `true`)
33
+ - **end** When `true` the regexp will match to the end of the string. (default: `true`)
34
+ - **start** When `true` the regexp will match from the beginning of the string. (default: `true`)
34
35
  - Advanced options (use for non-pathname strings, e.g. host names):
35
36
  - **delimiter** The default delimiter for segments. (default: `'/'`)
36
37
  - **endsWith** Optional character, or list of characters, to treat as "end" characters.
package/index.d.ts CHANGED
@@ -11,9 +11,13 @@ declare namespace pathToRegexp {
11
11
  */
12
12
  strict?: boolean;
13
13
  /**
14
- * When `false` the regexp will match the beginning instead of the entire string. (default: `true`)
14
+ * When `true` the regexp will match to the end of the string. (default: `true`)
15
15
  */
16
16
  end?: boolean;
17
+ /**
18
+ * When `true` the regexp will match from the beginning of the string. (default: `true`)
19
+ */
20
+ start?: boolean;
17
21
  /**
18
22
  * Sets the final character for non-ending optimistic matches. (default: `/`)
19
23
  */
package/index.js CHANGED
@@ -300,11 +300,12 @@ function tokensToRegExp (tokens, keys, options) {
300
300
  options = options || {}
301
301
 
302
302
  var strict = options.strict
303
+ var start = options.start !== false
303
304
  var end = options.end !== false
304
305
  var delimiter = escapeString(options.delimiter || DEFAULT_DELIMITER)
305
306
  var delimiters = options.delimiters || DEFAULT_DELIMITERS
306
307
  var endsWith = [].concat(options.endsWith || []).map(escapeString).concat('$').join('|')
307
- var route = ''
308
+ var route = start ? '^' : ''
308
309
  var isEndDelimited = tokens.length === 0
309
310
 
310
311
  // Iterate over the tokens and create our regexp string.
@@ -342,7 +343,7 @@ function tokensToRegExp (tokens, keys, options) {
342
343
  if (!isEndDelimited) route += '(?=' + delimiter + '|' + endsWith + ')'
343
344
  }
344
345
 
345
- return new RegExp('^' + route, flags(options))
346
+ return new RegExp(route, flags(options))
346
347
  }
347
348
 
348
349
  /**
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": "2.3.0",
4
+ "version": "2.4.0",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
7
7
  "files": [