Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

find-my-way

Package Overview
Dependencies
Maintainers
2
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

find-my-way - npm Package Compare versions

Comparing version 1.7.0 to 1.7.1

5

index.js

@@ -212,2 +212,3 @@ 'use strict'

if (handle !== undefined) {
var paramsObj = {}
if (handle.paramsLength > 0) {

@@ -217,3 +218,3 @@ var paramNames = handle.params

for (i = 0; i < handle.paramsLength; i++) {
handle.paramsObj[paramNames[i]] = params[i]
paramsObj[paramNames[i]] = params[i]
}

@@ -224,3 +225,3 @@ }

handler: handle.handler,
params: handle.paramsObj,
params: paramsObj,
store: handle.store

@@ -227,0 +228,0 @@ }

8

node.js

@@ -59,7 +59,2 @@ 'use strict'

var paramsObj = {}
for (var i = 0; i < params.length; i++) {
paramsObj[params[i]] = ''
}
this.map[method] = {

@@ -69,4 +64,3 @@ handler: handler,

store: store || null,
paramsLength: params.length,
paramsObj: paramsObj
paramsLength: params.length
}

@@ -73,0 +67,0 @@ }

{
"name": "find-my-way",
"version": "1.7.0",
"version": "1.7.1",
"description": "Crazy fast http radix based router",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -119,4 +119,5 @@ # find-my-way

```
This means that if you register two routes, the first static and the second dynamic with a shared part of the path, the static route will always take precedence.
For example:
##### Caveats
* Since *static* routes have greater priority than *parametric* routes, when you register a static route and a dynamic route, which have part of their path equal, the static route shadows the parametric route, that becomes not accessible. For example:
```js

@@ -141,2 +142,14 @@ const assert = require('assert')

* It's not possible to register two routes which differs only for their parameters, because internally they would be seen as the same route. In a such case you'll get an early error during the route registration phase. An example is worth thousand words:
```js
const findMyWay = FindMyWay({
defaultRoute: (req, res) => {}
})
findMyWay.on('GET', '/user/:userId(^\\d+)', (req, res, params) => {})
findMyWay.on('GET', '/user/:username(^[a-z]+)', (req, res, params) => {})
// Method 'GET' already declared for route ':'
```
<a name="shorthand-methods"></a>

@@ -143,0 +156,0 @@ ##### Shorthand methods

@@ -456,1 +456,23 @@ 'use strict'

})
test('params does not keep the object reference', t => {
t.plan(2)
const findMyWay = FindMyWay()
var first = true
findMyWay.on('GET', '/test/:id', (req, res, params) => {
if (first) {
setTimeout(() => {
t.is(params.id, 'hello')
}, 10)
} else {
setTimeout(() => {
t.is(params.id, 'world')
}, 10)
}
first = false
})
findMyWay.lookup({ method: 'GET', url: '/test/hello' }, null)
findMyWay.lookup({ method: 'GET', url: '/test/world' }, null)
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc