File tree Expand file tree Collapse file tree 3 files changed +24
-2
lines changed
Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ export const WebStandardAdapter: ElysiaAdapter = {
7979 const hasTrace = app . event . trace . length > 0
8080
8181 fnLiteral +=
82- `const u=r.url,` +
82+ `const u=decodeURI( r.url) ,` +
8383 `s=u.indexOf('/',${ standardHostname ? 11 : 7 } ),` +
8484 `qi=u.indexOf('?', s + 1)\n` +
8585 `let p\n` +
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ export const createDynamicHandler = (app: AnyElysia) => {
2929 const { mapResponse, mapEarlyResponse } = app [ '~adapter' ] . handler
3030
3131 return async ( request : Request ) : Promise < Response > => {
32- const url = request . url ,
32+ const url = decodeURI ( request . url ) ,
3333 s = url . indexOf ( '/' , 11 ) ,
3434 qi = url . indexOf ( '?' , s + 1 ) ,
3535 path = qi === - 1 ? url . substring ( s ) : url . substring ( s , qi )
Original file line number Diff line number Diff line change @@ -173,4 +173,26 @@ describe('Edge Case', () => {
173173 // @ts -expect-error private property
174174 expect ( main . getGlobalRoutes ( ) . length ) . toBe ( 2 )
175175 } )
176+
177+ describe ( 'handle path with spaces' , ( ) => {
178+ it ( 'when AOT is on' , async ( ) => {
179+ const PATH = "/y a y" ;
180+
181+ const app = new Elysia ( ) . get ( PATH , ( ) => "result from a path wirh spaces" ) ;
182+
183+ const response = await app . handle ( new Request ( `http://localhost${ PATH } ` ) ) ;
184+
185+ expect ( response . status ) . toBe ( 200 ) ;
186+ } )
187+
188+ it ( 'when AOT is off' , async ( ) => {
189+ const PATH = "/y a y" ;
190+
191+ const app = new Elysia ( { aot : false } ) . get ( PATH , ( ) => "result from a path wirh spaces" ) ;
192+
193+ const response = await app . handle ( new Request ( `http://localhost${ PATH } ` ) ) ;
194+
195+ expect ( response . status ) . toBe ( 200 ) ;
196+ } )
197+ } )
176198} )
You can’t perform that action at this time.
0 commit comments