@@ -67,19 +67,23 @@ private function getLivePropsToMap(Request $request): array
67
67
$ liveData = $ request ->attributes ->get ('_live_request_data ' ) ?? [];
68
68
$ values = array_merge ($ liveData ['props ' ] ?? [], $ liveData ['updated ' ] ?? []);
69
69
70
- $ urlLiveProps = [];
70
+ $ urlLiveProps = [
71
+ 'path ' => [],
72
+ 'query ' => []
73
+ ];
71
74
foreach ($ metadata ->getAllLivePropsMetadata ($ component ) as $ liveProp ) {
72
75
$ name = $ liveProp ->getName ();
73
76
$ urlMapping = $ liveProp ->urlMapping ();
74
77
if (isset ($ values [$ name ]) && $ urlMapping ) {
75
- $ urlLiveProps [$ urlMapping ->as ?? $ name ] = $ values [$ name ];
78
+ $ urlLiveProps [$ urlMapping ->mapPath ? 'path ' : 'query ' ][$ urlMapping ->as ?? $ name ] =
79
+ $ values [$ name ];
76
80
}
77
81
}
78
82
79
83
return $ urlLiveProps ;
80
84
}
81
85
82
- private function computeNewUrl (string $ previousUrl , array $ newProps ): string
86
+ private function computeNewUrl (string $ previousUrl , array $ livePropsToMap ): string
83
87
{
84
88
$ parsed = parse_url ($ previousUrl );
85
89
@@ -89,10 +93,16 @@ private function computeNewUrl(string $previousUrl, array $newProps): string
89
93
}
90
94
parse_str ($ parsed ['query ' ] ?? '' , $ previousQueryParams );
91
95
92
- return $ this ->router ->generate (
96
+ $ newUrl = $ this ->router ->generate (
93
97
$ this ->router ->match ($ url )['_route ' ],
94
- array_merge ($ previousQueryParams , $ newProps )
98
+ array_merge ($ previousQueryParams , $ livePropsToMap [ ' path ' ] )
95
99
);
100
+ parse_str (parse_url ($ newUrl )['query ' ] ?? '' , $ queryParams );
101
+ $ queryString = http_build_query (array_merge ($ queryParams , $ livePropsToMap ['query ' ]));
102
+
103
+ return preg_replace ('/[?#].*/ ' , '' , $ newUrl ) .
104
+ ('' !== $ queryString ? '? ' : '' ) .
105
+ $ queryString ;
96
106
}
97
107
98
108
/**
0 commit comments