You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
testing: after serveShellRequest serves a router, dispatch on the same router stops 308-redirecting a trailing-slash URL #1107
In a unit test, after serveShellRequest has served a router, calling dispatch on the same router with a trailing-slash URL no longer answers with the 308 redirect to the canonical URL. The route matches and renders instead. A fresh router gives the expected 308.
Reproduced with a plain server route, not only with clientUrls(), so it isn't specific to client routes.
Reproduction
import{serveShellRequest,dispatch}from"@rangojs/router/testing";constrouter=createRouter({/* a route at /products */});awaitserveShellRequest(router,"/products");// any shell request firstconstres=awaitdispatch(router,"/products/");// trailing slash// expected: res.status === 308, location: /products// actual: the route matches and renders (200)
With a separate router for the dispatch call, the 308 is returned as expected.
Expected
dispatch behaves the same whether or not the router was served by serveShellRequest before: a trailing-slash URL redirects with 308 to the canonical URL.
Notes
The likely cause is per-router state that serveShellRequest sets, for example on the matcher or the trailing-slash handling, leaking into later dispatches. This isn't verified.
Found while extending the testing helpers to serve clientUrls() modules. The new test works around it by using a separate router for its dispatch case.
Activity
fix(testing): dispatch matches through the route trie, as dev and pro…
fix(testing): dispatch matches through the route trie, as dev and pro…
fix(router): nested unnamed include() routes match; dispatch matches …