Skip to content

Commit

Permalink
released v4.0.27 - fixed toUpperCase serialization issue
Browse files Browse the repository at this point in the history
  • Loading branch information
kwhitley committed Jan 10, 2024
1 parent d3e8c95 commit 415b2c1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Changelog

- **v4.0.27**
- fixed: .toUpperCase issue that prevented serialization of entire router
- **v4.0.24**
- fixed: createResponse(undefined) should return undefined (not a Response)
- **v4.1.0**
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": "4.0.26",
"version": "4.0.27",
"description": "A tiny, zero-dependency router, designed to make beautiful APIs in any environment.",
"main": "./index.js",
"module": "./index.mjs",
Expand Down
6 changes: 6 additions & 0 deletions src/Router.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ describe('Router', () => {
expect(router.routes.length).toBe(3) // accessible off the main router
})

it('can serialize router without throwing', () => {
const router = Router().get('/', () => 'foo')

expect(() => console.log(router)).not.toThrow()
})

it('router.handle (legacy) is an alias for router.fetch (new)', () => {
expect(router.fetch).toBe(router.handle)
})
Expand Down
2 changes: 1 addition & 1 deletion src/Router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const Router = <
(route: string, ...handlers: RouteHandler<I>[]) =>
routes.push(
[
prop.toUpperCase(),
prop.toUpperCase?.(),
RegExp(`^${(path = (base + route)
.replace(/\/+(\/|$)/g, '$1')) // strip double & trailing splash
.replace(/(\/?\.?):(\w+)\+/g, '($1(?<$2>*))') // greedy params
Expand Down

0 comments on commit 415b2c1

Please sign in to comment.