find-my-way
Advanced tools
Comparing version 1.18.1 to 2.0.0
'use strict' | ||
const Benchmark = require('benchmark') | ||
// The default number of samples for Benchmark seems to be low enough that it | ||
// can generate results with significant variance (~2%) for this benchmark | ||
// suite. This makes it sometimes a bit confusing to actually evaluate impact of | ||
// changes on performance. Setting the minimum of samples to 500 results in | ||
// significantly lower variance on my local setup for this tests suite, and | ||
// gives me higher confidence in benchmark results. | ||
Benchmark.options.minSamples = 500 | ||
const suite = Benchmark.Suite() | ||
@@ -5,0 +13,0 @@ |
30
index.js
@@ -343,2 +343,9 @@ 'use strict' | ||
Router.prototype.find = function find (method, path, version) { | ||
if (path.charCodeAt(0) !== 47) { // 47 is '/' | ||
path = path.replace(FULL_PATH_REGEXP, '/') | ||
} | ||
var originalPath = path | ||
var originalPathLength = path.length | ||
if (this.caseSensitive === false) { | ||
@@ -348,6 +355,2 @@ path = path.toLowerCase() | ||
if (path.charCodeAt(0) !== 47) { // 47 is '/' | ||
path = path.replace(FULL_PATH_REGEXP, '/') | ||
} | ||
var maxParamLength = this.maxParamLength | ||
@@ -357,4 +360,2 @@ var currentNode = this.tree | ||
var pathLenWildcard = 0 | ||
var originalPath = path | ||
var originalPathLength = path.length | ||
var decoded = null | ||
@@ -364,2 +365,3 @@ var pindex = 0 | ||
var i = 0 | ||
var idxInOriginalPath = 0 | ||
@@ -372,3 +374,2 @@ while (true) { | ||
var previousPath = path | ||
// found the route | ||
@@ -404,2 +405,3 @@ if (pathLen === 0 || path === prefix) { | ||
pathLen = path.length | ||
idxInOriginalPath += len | ||
} | ||
@@ -424,2 +426,4 @@ | ||
} | ||
idxInOriginalPath = idxInOriginalPath - | ||
(previousPath.length - path.length) | ||
path = previousPath | ||
@@ -429,2 +433,3 @@ pathLen = previousPath.length | ||
} | ||
var kind = node.kind | ||
@@ -459,6 +464,7 @@ | ||
if (i > maxParamLength) return null | ||
decoded = fastDecode(path.slice(0, i)) | ||
decoded = fastDecode(originalPath.slice(idxInOriginalPath, idxInOriginalPath + i)) | ||
if (decoded === null) return null | ||
params[pindex++] = decoded | ||
path = path.slice(i) | ||
idxInOriginalPath += i | ||
continue | ||
@@ -469,3 +475,3 @@ } | ||
if (kind === NODE_TYPES.MATCH_ALL) { | ||
decoded = fastDecode(path) | ||
decoded = fastDecode(originalPath.slice(idxInOriginalPath)) | ||
if (decoded === null) return null | ||
@@ -484,3 +490,3 @@ params[pindex] = decoded | ||
if (i > maxParamLength) return null | ||
decoded = fastDecode(path.slice(0, i)) | ||
decoded = fastDecode(originalPath.slice(idxInOriginalPath, idxInOriginalPath + i)) | ||
if (decoded === null) return null | ||
@@ -490,2 +496,3 @@ if (!node.regex.test(decoded)) return null | ||
path = path.slice(i) | ||
idxInOriginalPath += i | ||
continue | ||
@@ -506,6 +513,7 @@ } | ||
} | ||
decoded = fastDecode(path.slice(0, i)) | ||
decoded = fastDecode(originalPath.slice(idxInOriginalPath, idxInOriginalPath + i)) | ||
if (decoded === null) return null | ||
params[pindex++] = decoded | ||
path = path.slice(i) | ||
idxInOriginalPath += i | ||
continue | ||
@@ -512,0 +520,0 @@ } |
{ | ||
"name": "find-my-way", | ||
"version": "1.18.1", | ||
"version": "2.0.0", | ||
"description": "Crazy fast http radix based router", | ||
@@ -11,3 +11,3 @@ "main": "index.js", | ||
"test": "standard && tap -j4 test/*.test.js && npm run test:typescript", | ||
"coveralls": "if [[ $(node -v) != \"v4.9.1\" ]]; then tap -j4 test/*.test.js --cov --coverage-report=text-lcov | coveralls; fi" | ||
"coveralls": "tap -j4 test/*.test.js --cov --coverage-report=text-lcov | coveralls;" | ||
}, | ||
@@ -25,2 +25,5 @@ "repository": { | ||
], | ||
"engines": { | ||
"node": ">=6" | ||
}, | ||
"author": "Tomas Della Vedova - @delvedor (http://delved.org)", | ||
@@ -33,3 +36,3 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@types/node": "^10.12.12", | ||
"@types/node": "^11.9.4", | ||
"benchmark": "^2.1.4", | ||
@@ -40,10 +43,10 @@ "coveralls": "^3.0.2", | ||
"standard": "^12.0.1", | ||
"tap": "12.4.0", | ||
"typescript": "^3.2.1" | ||
"tap": "^12.5.3", | ||
"typescript": "^3.3.3" | ||
}, | ||
"dependencies": { | ||
"fast-decode-uri-component": "^1.0.0", | ||
"safe-regex": "^1.1.0", | ||
"safe-regex": "^2.0.1", | ||
"semver-store": "^0.3.0" | ||
} | ||
} |
@@ -81,5 +81,3 @@ # find-my-way | ||
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: | ||
in that case, all paths will be matched as lowercase, but the route parameters or wildcards will maintain their original letter casing. You can turn off case sensitivity with: | ||
@@ -86,0 +84,0 @@ ```js |
Sorry, the diff of this file is not supported yet
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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
156288
4411
1
354
+ Addedregexp-tree@0.1.27(transitive)
+ Addedsafe-regex@2.1.1(transitive)
- Removedret@0.1.15(transitive)
- Removedsafe-regex@1.1.0(transitive)
Updatedsafe-regex@^2.0.1