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 +5 -0
- package/Readme.md +2 -1
- package/index.d.ts +5 -1
- package/index.js +3 -2
- package/package.json +1 -1
package/History.md
CHANGED
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 `
|
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 `
|
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(
|
346
|
+
return new RegExp(route, flags(options))
|
346
347
|
}
|
347
348
|
|
348
349
|
/**
|