path-to-regexp 1.7.0 → 1.8.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/index.d.ts +9 -2
- package/index.js +4 -4
- package/package.json +1 -1
package/History.md
CHANGED
package/index.d.ts
CHANGED
@@ -33,6 +33,13 @@ declare namespace pathToRegexp {
|
|
33
33
|
delimiter?: string;
|
34
34
|
}
|
35
35
|
|
36
|
+
export interface TokensToFunctionOptions {
|
37
|
+
/**
|
38
|
+
* When `true` the regexp will be case sensitive. (default: `false`)
|
39
|
+
*/
|
40
|
+
sensitive?: boolean;
|
41
|
+
}
|
42
|
+
|
36
43
|
/**
|
37
44
|
* Parse an Express-style path into an array of tokens.
|
38
45
|
*/
|
@@ -41,12 +48,12 @@ declare namespace pathToRegexp {
|
|
41
48
|
/**
|
42
49
|
* Transforming an Express-style path into a valid path.
|
43
50
|
*/
|
44
|
-
export function compile (path: string, options?: ParseOptions): PathFunction;
|
51
|
+
export function compile (path: string, options?: ParseOptions & TokensToFunctionOptions): PathFunction;
|
45
52
|
|
46
53
|
/**
|
47
54
|
* Transform an array of tokens into a path generator function.
|
48
55
|
*/
|
49
|
-
export function tokensToFunction (tokens: Token[]): PathFunction;
|
56
|
+
export function tokensToFunction (tokens: Token[], options?: TokensToFunctionOptions): PathFunction;
|
50
57
|
|
51
58
|
/**
|
52
59
|
* Transform an array of tokens into a matching regular expression.
|
package/index.js
CHANGED
@@ -108,7 +108,7 @@ function parse (str, options) {
|
|
108
108
|
* @return {!function(Object=, Object=)}
|
109
109
|
*/
|
110
110
|
function compile (str, options) {
|
111
|
-
return tokensToFunction(parse(str, options))
|
111
|
+
return tokensToFunction(parse(str, options), options)
|
112
112
|
}
|
113
113
|
|
114
114
|
/**
|
@@ -138,14 +138,14 @@ function encodeAsterisk (str) {
|
|
138
138
|
/**
|
139
139
|
* Expose a method for transforming tokens into the path function.
|
140
140
|
*/
|
141
|
-
function tokensToFunction (tokens) {
|
141
|
+
function tokensToFunction (tokens, options) {
|
142
142
|
// Compile all the tokens into regexps.
|
143
143
|
var matches = new Array(tokens.length)
|
144
144
|
|
145
145
|
// Compile all the patterns before compilation.
|
146
146
|
for (var i = 0; i < tokens.length; i++) {
|
147
147
|
if (typeof tokens[i] === 'object') {
|
148
|
-
matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$')
|
148
|
+
matches[i] = new RegExp('^(?:' + tokens[i].pattern + ')$', flags(options))
|
149
149
|
}
|
150
150
|
}
|
151
151
|
|
@@ -258,7 +258,7 @@ function attachKeys (re, keys) {
|
|
258
258
|
* @return {string}
|
259
259
|
*/
|
260
260
|
function flags (options) {
|
261
|
-
return options.sensitive ? '' : 'i'
|
261
|
+
return options && options.sensitive ? '' : 'i'
|
262
262
|
}
|
263
263
|
|
264
264
|
/**
|