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.1 to 0.5.2

2

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

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

@@ -17,3 +17,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(/(\/:([^\/\?]+)(\?)?)/gi, '/$3(?<$2>[^\/]+)$3')}$`, handler]) && obj
})

@@ -20,0 +20,0 @@

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

let routes = [
{ path: '/', callback: jest.fn(extract), method: 'get' },
{ path: '/foo/first', callback: jest.fn(extract), method: 'get' },

@@ -36,2 +37,10 @@ { path: '/foo/:id', callback: jest.fn(extract), method: 'get' },

it('requires exact route match', () => {
const route = routes.find(r => r.path === '/')
router.handle(buildRequest({ path: '/foo' }))
expect(route.callback).not.toHaveBeenCalled()
})
it('match earliest routes that match', () => {

@@ -38,0 +47,0 @@ const route = routes.find(r => r.path === '/foo/first')

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