Skip to content

Commit

Permalink
released v2.0.2 - slight improvement in prebuild and fixed README cod…
Browse files Browse the repository at this point in the history
…e to reflect latest
  • Loading branch information
kwhitley committed Feb 24, 2021
1 parent f353a4c commit 493808c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,27 +176,27 @@ router.handle({ url: 'https://example.com/user' }) // --> STATUS 200: { name: 'M
const Router = (o = {}) =>
new Proxy(o, {
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)) {
r.params = m.groups
r.query = Object.fromEntries(u.searchParams.entries())
for (h of hs) {
if ((s = await h(r, ...args)) !== undefined) return s
if ((s = await h(r, ...a)) !== undefined) return s
}
}
}
}
: (p, ...hs) =>
(t.r = t.r || []).push([
k.toUpperCase(),
`^${(t.base || '')+p
.replace(/(\/?)\*/g, '($1.*)?')
.replace(/\/$/, '')
.replace(/:([^\/\?\.]+)(\?)?/g, '$2(?<$1>[^/\.]+)$2')
}\/*$`,
hs
hs,
k.toUpperCase(),
]) && c
})
```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "itty-router",
"version": "2.0.1",
"version": "2.0.2",
"description": "Tiny, zero-dependency router with route param and query parsing.",
"main": "./dist/itty-router.min.js",
"types": "./dist/itty-router.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion prebuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ const minifiedBase = base
.replace(/([^\.])obj\b/g, '$1t') // Target
.replace(/([^\.])options\b/g, '$1o') // Options
.replace(/([^\.])receiver\b/g, '$1c') // Options
.replace(/([^\.])attr\b/g, '$1a') // Attr
.replace(/([^\.])route\b/g, '$1p') // Path
.replace(/([^\.])\.routes\b/g, '$1\.r') // routes Queue
.replace(/args/g, 'a') // Args
.replace(/([^\.])request\b/g, '$1r') // Request
.replace(/([^\.])response\b/g, '$1s') // reSponse
.replace(/([^\.])match\b/g, '$1m') // Match
Expand Down

0 comments on commit 493808c

Please sign in to comment.