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

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.9.1 to 0.9.2

2

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

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

@@ -154,16 +154,23 @@ ![image](https://user-images.githubusercontent.com/865416/79531114-fa0d8200-8036-11ea-824d-70d84164b00a.png)

```js
const Router = () => new Proxy({}, {
get: (o, k) => k === 'handle'
? (c) => {
for ([r, h] of o[(c.method || 'GET').toLowerCase()] || []) {
if (m = (u = new URL(c.url)).pathname.match(r)) {
return h(Object.assign(c, {
params: m.groups,
query: Object.fromEntries(u.searchParams.entries())
}))
const Router = () =>
new Proxy({}, {
get: (o, k) => k === 'handle'
? async (c) => {
for ([r, hs] of o[(c.method || 'GET').toLowerCase()] || []) {
if (m = (u = new URL(c.url)).pathname.match(r)) { // r matched
Object.assign(c, {
params: m.groups,
query: Object.fromEntries(u.searchParams.entries()),
})
for (h of hs) {
if ((response = await h(c)) !== undefined) return response
}
}
}
}
} : (p, h) =>
(o[k] = o[k] || []).push([`^${p.replace('*', '.*').replace(/(\/:([^\/\?]+)(\?)?)/gi, '/$3(?<$2>[^\/]+)$3')}$`, h]) && o
})
: (p, ...hs) =>
(o[k] = o[k] || []).push([`^${p.replace('*', '.*').replace(/(\/:([^\/\?]+)(\?)?)/gi, '/$3(?<$2>[^/]+)$3')}$`, hs]) && o
}
)
```

@@ -170,0 +177,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