File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
packages/forms/src/form-tools Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -45,8 +45,22 @@ export default class FormsReact {
4545
4646 return {
4747 search,
48- redirect ( status ?: ValidRedirectStatus ) {
49- const pathWithSearch = url . pathname . split ( '/' ) . pop ( ) + search . toString ( ) ;
48+ redirect ( status ?: ValidRedirectStatus , removeEmptyParams = true ) {
49+ const copySearch = new URLSearchParams ( search ) ;
50+ if ( removeEmptyParams ) {
51+ for ( const [ key , value ] of copySearch . entries ( ) ) {
52+ if ( value === '' || value == null ) {
53+ copySearch . delete ( key ) ;
54+ }
55+ }
56+ }
57+
58+ const searchString = copySearch . toString ( ) ;
59+ let pathWithSearch = url . pathname . split ( '/' ) . pop ( ) ;
60+ if ( searchString ) {
61+ pathWithSearch += '?' + searchString ;
62+ }
63+
5064 self . overrideResponse = new Response ( null , {
5165 status : status || 302 ,
5266 headers : {
You can’t perform that action at this time.
0 commit comments