Socket
Socket
Sign inDemoInstall

itty-router

Package Overview
Dependencies
Maintainers
1
Versions
265
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

itty-router - npm Package Compare versions

Comparing version 0.5.3 to 0.5.4

2

package.json
{
"name": "itty-router",
"version": "0.5.3",
"version": "0.5.4",
"description": "Tiny, zero-dependency router with route param and query parsing.",

@@ -5,0 +5,0 @@ "main": "src/Router.js",

@@ -16,3 +16,3 @@ const Router = () => new Proxy({}, {

: (path, handler) =>
(obj[prop] = obj[prop] || []).push([`^${path.replace(/(\/:([^\/\?]+)(\?)?)/gi, '/$3(?<$2>[^\/]+)$3')}$`, handler]) && obj
(obj[prop] = obj[prop] || []).push([`^${path.replace('*', '.*').replace(/(\/:([^\/\?]+)(\?)?)/gi, '/$3(?<$2>[^\/]+)$3')}$`, handler]) && obj
})

@@ -19,0 +19,0 @@

@@ -15,2 +15,3 @@ const { Router } = require('./Router')

{ path: '/passthrough', callback: jest.fn(({ path, name }) => ({ path, name })), method: 'get' },
{ path: '*', callback: jest.fn(), method: 'get' },
]

@@ -78,3 +79,10 @@

})
it('accepts * as a wildcard route (e.g. for use in 404)', () => {
const route = routes.find(r => r.path === '*')
router.handle(buildRequest({ path: '/missing' }))
expect(route.callback).toHaveBeenCalled()
})
})
})
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