File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -44,8 +44,9 @@ public function build($absolute = true)
4444 {
4545 $ host = $ absolute ? $ this ->get ('scheme ' ) . ':// ' . $ this ->get ('host ' ) . $ this ->get ('port ' ) : '' ;
4646 $ path = '/ ' . trim ($ this ->get ('path ' ), '/ ' );
47+ $ query = $ this ->get ('query ' ) ? '? ' . $ this ->get ('query ' ) : '' ;
4748
48- return $ host . $ path ;
49+ return $ host . $ path . $ query ;
4950 }
5051
5152 /**
Original file line number Diff line number Diff line change @@ -564,6 +564,28 @@ public function it_generates_non_absolute_urls_for_non_existing_routes()
564564 $ this ->assertEquals ('/en/route/does/not/exist ' , trim ($ response ->original ));
565565 }
566566
567+ /** @test */
568+ public function it_returns_a_url_with_query_string ()
569+ {
570+ $ this ->setSupportedLocales (['en ' , 'nl ' ]);
571+
572+ Route::get ('route ' , function () {
573+ return [
574+ 'current ' => Route::localizedUrl (),
575+ 'en ' => Route::localizedUrl ('en ' ),
576+ 'nl ' => Route::localizedUrl ('nl ' ),
577+ ];
578+ });
579+
580+ $ response = $ this ->call ('GET ' , '/route?another=one¶m=value ' );
581+ $ response ->assertOk ();
582+ $ this ->assertEquals ([
583+ 'current ' => url ('/route?another=one¶m=value ' ),
584+ 'en ' => url ('/route?another=one¶m=value ' ),
585+ 'nl ' => url ('/route?another=one¶m=value ' ),
586+ ], $ response ->original );
587+ }
588+
567589 /**
568590 * Set a custom view path so Laravel will find our custom 440 error view.
569591 *
You can’t perform that action at this time.
0 commit comments