Skip to content

Releases: kwhitley/itty-router

v2.3.9

30 May 05:32
Compare
Choose a tag to compare
released v2.3.9 - developer QOL fixes <3

v2.1.9

06 Mar 01:55
Compare
Choose a tag to compare

Migrating from 1.x to 2.x

TLDR; Most people will not be affected at all and can upgrade without issue

In 2.x, itty changed the handling of the *all channel from executing before all other methods (effectively an upstream catch-all method), to handling in-order like all other routes, just bypassing the method match (therefore matching any method type). While this could technically be considered a fix, the behavior COULD have been planned around intentionally in the previous release, thus the need for a breaking change/major release.

The following example demonstrates the changes in the all channel execution:

v1.x

router
  .all('*', middleware) // applied before
  .get('/foo', () => new Response('middleware is applied'))

// is equivalent to this "backwards" example, because the "all" is executed first

router
  .get('/foo', () => new Response('middleware is applied'))
  .all('*', middleware) // applied before, despite being registered afterwards

// leading to this weird behavior... where a final "catch-all" will in fact intercept all previous routes...

router
  .all('*', middleware) // still applies first...
  .get('/foo', () => new Response('This route will NEVER match... RIP.'))
  .all('*', () => new Response('Not found', { status: 404 })) // will catch everything before the previous line

v2.x

router
  .all('*', middleware) // still applies first...
  .get('/foo', () => new Response('This route WILL properly match!  woohoo!... RIP'))
  .all('*', () => new Response('Not found', { status: 404 })) // will only catch if no previous match... as expected.

v1.1.0

29 May 04:57
Compare
Choose a tag to compare

Changelog

Features

  • Added single config option to Router({ base: '/some/path' }) for route prefixing
  • Verified wildcards work in the middle of path (e.g. /foo/*/end matches /foo/bar/baz/end)

Fixes

  • trailing wildcards (often used in middleware or for sub routers) now properly routes without requiring trailing slash (e.g. /foo/* should match /foo)