File tree Expand file tree Collapse file tree 2 files changed +3
-8
lines changed Expand file tree Collapse file tree 2 files changed +3
-8
lines changed Original file line number Diff line number Diff line change @@ -51,15 +51,10 @@ export function createRouter (opts: CreateRouterOptions = {}): Router {
51
51
52
52
// Main handle
53
53
router . handler = eventHandler ( ( event ) => {
54
- // Match route
55
-
56
54
// Remove query parameters for matching
57
- let path = event . req . url || '/'
58
- const queryUrlIndex = path . lastIndexOf ( '?' )
59
- if ( queryUrlIndex > - 1 ) {
60
- path = path . substring ( 0 , queryUrlIndex )
61
- }
55
+ const path = new URL ( event . req . url || '/' , 'http://localhost' ) . pathname
62
56
57
+ // Match route
63
58
const matched = _router . lookup ( path )
64
59
if ( ! matched ) {
65
60
if ( opts . preemtive ) {
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ describe('router', () => {
50
50
} )
51
51
52
52
it ( 'Handle url with query parameters, include "?" in url path' , async ( ) => {
53
- const res = await request . get ( '/test/?/a?title=test' )
53
+ const res = await request . get ( '/test/?/a?title=test&returnTo=/path?foo=bar ' )
54
54
expect ( res . status ) . toEqual ( 200 )
55
55
} )
56
56
You can’t perform that action at this time.
0 commit comments