itty-router
Advanced tools
Comparing version 0.5.3 to 0.5.4
{ | ||
"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() | ||
}) | ||
}) | ||
}) |
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
9421
85