find-my-way
Advanced tools
Comparing version 1.14.1 to 1.15.0
17
index.js
@@ -35,2 +35,3 @@ 'use strict' | ||
this.caseSensitive = opts.caseSensitive === undefined ? true : opts.caseSensitive | ||
this.ignoreTrailingSlash = opts.ignoreTrailingSlash || false | ||
@@ -100,4 +101,10 @@ this.maxParamLength = opts.maxParamLength || 100 | ||
j = i + 1 | ||
var staticPart = path.slice(0, i) | ||
if (this.caseSensitive === false) { | ||
staticPart = staticPart.toLowerCase() | ||
} | ||
// add the static part of the route to the tree | ||
this._insert(method, path.slice(0, i), 0, null, null, null, null, version) | ||
this._insert(method, staticPart, 0, null, null, null, null, version) | ||
@@ -154,2 +161,7 @@ // isolate the parameter name | ||
} | ||
if (this.caseSensitive === false) { | ||
path = path.toLowerCase() | ||
} | ||
// static route | ||
@@ -314,2 +326,5 @@ this._insert(method, path, 0, params, handler, store, null, version) | ||
Router.prototype.find = function find (method, path, version) { | ||
if (this.caseSensitive === false) { | ||
path = path.toLowerCase() | ||
} | ||
var maxParamLength = this.maxParamLength | ||
@@ -316,0 +331,0 @@ var currentNode = this.tree |
{ | ||
"name": "find-my-way", | ||
"version": "1.14.1", | ||
"version": "1.15.0", | ||
"description": "Crazy fast http radix based router", | ||
@@ -30,3 +30,3 @@ "main": "index.js", | ||
"benchmark": "^2.1.4", | ||
"coveralls": "^3.0.1", | ||
"coveralls": "^3.0.2", | ||
"pre-commit": "^1.2.2", | ||
@@ -33,0 +33,0 @@ "request": "^2.87.0", |
@@ -57,3 +57,3 @@ # find-my-way | ||
function handler (req, res, params) { | ||
res.send('foo') | ||
res.end('foo') | ||
} | ||
@@ -79,2 +79,15 @@ // maps "/foo/" and "/foo" to `handler` | ||
``` | ||
According to [RFC3986](https://tools.ietf.org/html/rfc3986#section-6.2.2.1), find-my-way is case sensitive by default. | ||
You can disable this by setting the `caseSensitive` option to `false`: | ||
in that case all paths will be lowercased before routing, including | ||
parametric and regexp-matched values. You can turn off case sensitivity | ||
with: | ||
```js | ||
const router = require('find-my-way')({ | ||
caseSensitive: false | ||
}) | ||
``` | ||
<a name="on"></a> | ||
@@ -81,0 +94,0 @@ #### on(method, path, [opts], handler, [store]) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
129102
29
3676
294
1