File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -301,7 +301,10 @@ export class App<State> {
301301 ensureHandler ( route ) ;
302302 middlewares . push ( ( ctx ) => renderRoute ( ctx , route ) ) ;
303303
304- const routePath = route . config ?. routeOverride ?? path ;
304+ const routePath = mergePath (
305+ this . config . basePath ,
306+ route . config ?. routeOverride ?? path ,
307+ ) ;
305308
306309 if ( typeof route . handler === "function" ) {
307310 this . #addRoute( "ALL" , routePath , middlewares ) ;
Original file line number Diff line number Diff line change @@ -631,3 +631,19 @@ Deno.test("App - uses notFound route on 404", async () => {
631631 res = await server . get ( "/thrower_2" ) ;
632632 expect ( await res . text ( ) ) . toEqual ( "error route" ) ;
633633} ) ;
634+
635+ // Issue: https://github.com/denoland/fresh/issues/3115
636+ Deno . test ( "App - .route() with basePath" , async ( ) => {
637+ const app = new App ( { basePath : "/foo/bar" } )
638+ . route ( "/" , { handler : ( ) => new Response ( "ok" ) } ) ;
639+
640+ const server = new FakeServer ( app . handler ( ) ) ;
641+
642+ let res = await server . delete ( "/" ) ;
643+ expect ( res . status ) . toEqual ( 404 ) ;
644+ res = await server . delete ( "/foo" ) ;
645+ expect ( res . status ) . toEqual ( 404 ) ;
646+
647+ res = await server . delete ( "/foo/bar" ) ;
648+ expect ( res . status ) . toEqual ( 200 ) ;
649+ } ) ;
You can’t perform that action at this time.
0 commit comments