File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -728,6 +728,19 @@ public function forceScheme($scheme)
728
728
$ this ->forceScheme = $ scheme ? $ scheme .':// ' : null ;
729
729
}
730
730
731
+ /**
732
+ * Force the use of the HTTPS scheme for all generated URLs.
733
+ *
734
+ * @param bool $force
735
+ * @return void
736
+ */
737
+ public function forceHttps ($ force = true )
738
+ {
739
+ if ($ force ) {
740
+ $ this ->forceScheme ('https ' );
741
+ }
742
+ }
743
+
731
744
/**
732
745
* Set the forced root URL.
733
746
*
Original file line number Diff line number Diff line change 30
30
* @method static void defaults(array $defaults)
31
31
* @method static array getDefaultParameters()
32
32
* @method static void forceScheme(string|null $scheme)
33
+ * @method static void forceHttps(bool $force = true)
33
34
* @method static void forceRootUrl(string|null $root)
34
35
* @method static \Illuminate\Routing\UrlGenerator formatHostUsing(\Closure $callback)
35
36
* @method static \Illuminate\Routing\UrlGenerator formatPathUsing(\Closure $callback)
Original file line number Diff line number Diff line change @@ -716,6 +716,20 @@ public function testForceRootUrl()
716
716
$ this ->assertSame ('https://www.bar.com/foo ' , $ url ->route ('plain ' ));
717
717
}
718
718
719
+ public function testForceHttps ()
720
+ {
721
+ $ url = new UrlGenerator (
722
+ $ routes = new RouteCollection ,
723
+ Request::create ('http://www.foo.com/ ' )
724
+ );
725
+
726
+ $ url ->forceHttps ();
727
+ $ route = new Route (['GET ' ], '/foo ' , ['as ' => 'plain ' ]);
728
+ $ routes ->add ($ route );
729
+
730
+ $ this ->assertSame ('https://www.foo.com/foo ' , $ url ->route ('plain ' ));
731
+ }
732
+
719
733
public function testPrevious ()
720
734
{
721
735
$ url = new UrlGenerator (
You can’t perform that action at this time.
0 commit comments