Commit 5fba571 1 parent c9426e3 commit 5fba571 Copy full SHA for 5fba571
File tree 3 files changed +28
-3
lines changed
__fixtures__/test-project/web
3 files changed +28
-3
lines changed Original file line number Diff line number Diff line change 23
23
"@redwoodjs/vite" : " 6.0.7" ,
24
24
"@types/react" : " 18.2.37" ,
25
25
"@types/react-dom" : " 18.2.15" ,
26
- "autoprefixer" : " ^10.4.16 " ,
26
+ "autoprefixer" : " ^10.4.17 " ,
27
27
"postcss" : " ^8.4.33" ,
28
28
"postcss-loader" : " ^8.0.0" ,
29
29
"prettier-plugin-tailwindcss" : " 0.4.1" ,
Original file line number Diff line number Diff line change @@ -427,4 +427,26 @@ describe('replaceParams', () => {
427
427
'/a/1/c/2/e'
428
428
)
429
429
} )
430
+
431
+ // See link below for the rules
432
+ // https://blog.lunatech.com/posts/2009-02-03-what-every-web-developer-must-know-about-url-encoding
433
+ it ( 'properly encodes search parameters' , ( ) => {
434
+ expect ( replaceParams ( '/search' , { q : 'foo bar' } ) ) . toEqual (
435
+ '/search?q=foo+bar'
436
+ )
437
+
438
+ expect ( replaceParams ( '/index-value' , { 's&p500' : '2024-01-17' } ) ) . toEqual (
439
+ '/index-value?s%26p500=2024-01-17'
440
+ )
441
+
442
+ expect ( replaceParams ( '/search' , { q : 'home & garden' } ) ) . toEqual (
443
+ '/search?q=home+%26+garden'
444
+ )
445
+
446
+ expect ( replaceParams ( '/dir' , { path : '/Users/rob/Photos' } ) ) . toEqual (
447
+ '/dir?path=%2FUsers%2Frob%2FPhotos'
448
+ )
449
+
450
+ expect ( replaceParams ( '/calc' , { expr : '1+2' } ) ) . toEqual ( '/calc?expr=1%2B2' )
451
+ } )
430
452
} )
Original file line number Diff line number Diff line change @@ -341,8 +341,11 @@ export function replaceParams(
341
341
} )
342
342
343
343
// Append any unnamed params as search params.
344
- if ( queryParams . length ) {
345
- path += `?${ queryParams . join ( '&' ) } `
344
+ if ( extraArgKeys . length ) {
345
+ const extraArgs = Object . fromEntries (
346
+ extraArgKeys . map ( ( key ) => [ key , `${ args [ key ] } ` ] )
347
+ )
348
+ path += `?${ new URLSearchParams ( extraArgs ) . toString ( ) } `
346
349
}
347
350
348
351
return path
You can’t perform that action at this time.
0 commit comments