Socket
Socket
Sign inDemoInstall

itty-router

Package Overview
Dependencies
Maintainers
2
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 2.0.1 to 2.0.2

4

dist/itty-router.js
const Router = (o = {}) =>
new Proxy(o, {
get: (t, k, c) => k === 'handle'
? async (r, ...args) => {
? async (r, ...a) => {
for ([p, hs] of t.r.filter(r => r[0] === r.method || 'ALL')) {

@@ -11,3 +11,3 @@ if (m = (u = new URL(r.url)).pathname.match(p)) {

for (h of hs) {
if ((s = await h(r, ...args)) !== undefined) return s
if ((s = await h(r, ...a)) !== undefined) return s
}

@@ -14,0 +14,0 @@ }

{
"name": "itty-router",
"version": "2.0.1",
"version": "2.0.2",
"description": "Tiny, zero-dependency router with route param and query parsing.",

@@ -5,0 +5,0 @@ "main": "./dist/itty-router.min.js",

@@ -14,3 +14,3 @@ ![Logo][logo-image]

```
yarn add itty-router
npm install itty-router
```

@@ -45,3 +45,3 @@

# Features
- [x] tiny (<450 bytes) with zero dependencies
- [x] tiny (~450 bytes) with zero dependencies
- [x] route params, with optionals (e.g. `/api/:foo/:id?.:format?`)

@@ -181,4 +181,4 @@ - [x] bonus query parsing (e.g. `?page=3&foo-bar`)

get: (t, k, c) => k === 'handle'
? async (r, ...args) => {
for ([, p, hs] of t.r.filter(r => r[0] === r.method || 'ALL')) {
? async (r, ...a) => {
for ([p, hs] of t.r.filter(r => r[0] === r.method || 'ALL')) {
if (m = (u = new URL(r.url)).pathname.match(p)) {

@@ -189,3 +189,3 @@ r.params = m.groups

for (h of hs) {
if ((s = await h(r, ...args)) !== undefined) return s
if ((s = await h(r, ...a)) !== undefined) return s
}

@@ -197,3 +197,2 @@ }

(t.r = t.r || []).push([
k.toUpperCase(),
`^${(t.base || '')+p

@@ -204,3 +203,4 @@ .replace(/(\/?)\*/g, '($1.*)?')

}\/*$`,
hs
hs,
k.toUpperCase(),
]) && c

@@ -207,0 +207,0 @@ })

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