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 CHANGED
@@ -1,3 +1,8 @@
1
+ 1.7.0 / 2016-11-08
2
+ ==================
3
+
4
+ * Allow a `delimiter` option to be passed in with `tokensToRegExp` which will be used for "non-ending" token match situations
5
+
1
6
  1.6.0 / 2016-10-03
2
7
  ==================
3
8
 
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
  /**
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": "1.7.0",
4
+ "version": "1.8.0",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
7
7
  "files": [