@@ -260,6 +260,62 @@ public function it_merges_query_strings()
260260 $ this ->assertTrue ($ response ->isRedirect (url ('/fr?another=value&lang=fr ' )));
261261 }
262262
263+ /**
264+ * @test
265+ */
266+ public function it_merges_query_strings_on_urls_without_path ()
267+ {
268+ config ()->set ('statamic.redirect.preserve_query_strings ' , true );
269+
270+ Redirect::make ()
271+ ->source ('/abc?another=value ' )
272+ ->destination ('?lang=fr ' )
273+ ->save ();
274+
275+ $ response = $ this ->middleware ->handle (Request::create ('/abc ' , 'GET ' , ['another ' => 'value ' ]), function () {
276+ return (new Response ('' , 404 ));
277+ });
278+
279+ $ this ->assertTrue ($ response ->isRedirect (url ('?another=value&lang=fr ' )));
280+ }
281+
282+ /**
283+ * @test
284+ */
285+ public function it_merges_query_strings_on_urls_with_fragment ()
286+ {
287+ config ()->set ('statamic.redirect.preserve_query_strings ' , true );
288+
289+ Redirect::make ()
290+ ->source ('/abc?another=value ' )
291+ ->destination ('/abc?lang=fr#some-fragment?with=fragment_param ' )
292+ ->save ();
293+
294+ $ response = $ this ->middleware ->handle (Request::create ('/abc ' , 'GET ' , ['another ' => 'value ' ]), function () {
295+ return (new Response ('' , 404 ));
296+ });
297+
298+ $ this ->assertTrue ($ response ->isRedirect (url ('/abc?another=value&lang=fr#some-fragment?with=fragment_param ' )));
299+ }
300+
301+ /**
302+ * @test
303+ */
304+ public function it_merges_query_strings_on_urls_without_path_with_fragment ()
305+ {
306+ config ()->set ('statamic.redirect.preserve_query_strings ' , true );
307+
308+ Redirect::make ()
309+ ->source ('/abc?another=value ' )
310+ ->destination ('?lang=fr#some-fragment?with=fragment_param ' )
311+ ->save ();
312+
313+ $ response = $ this ->middleware ->handle (Request::create ('/abc ' , 'GET ' , ['another ' => 'value ' ]), function () {
314+ return (new Response ('' , 404 ));
315+ });
316+
317+ $ this ->assertTrue ($ response ->isRedirect (url ('?another=value&lang=fr#some-fragment?with=fragment_param ' )));
318+ }
263319
264320
265321 /**
0 commit comments