File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -596,7 +596,7 @@ public function __toString(): string
596596 }
597597
598598 // Check for forced HTTPS
599- if ($ config ->forceGlobalSecureRequests ) {
599+ if ($ config ->forceGlobalSecureRequests && $ this -> getScheme () === ' http ' ) {
600600 $ scheme = 'https ' ;
601601 }
602602 }
Original file line number Diff line number Diff line change @@ -985,4 +985,20 @@ public function testCreateURIString()
985985
986986 $ this ->assertSame ($ expected , $ uri );
987987 }
988+
989+ /**
990+ * @see https://github.com/codeigniter4/CodeIgniter4/issues/5728
991+ */
992+ public function testForceGlobalSecureRequestsAndNonHTTPProtocol ()
993+ {
994+ $ config = new App ();
995+ $ config ->forceGlobalSecureRequests = true ;
996+ $ config ->baseURL = 'https://localhost/ ' ;
997+ Factories::injectMock ('config ' , 'App ' , $ config );
998+
999+ $ expected = 'ftp://localhost/path/to/test.txt ' ;
1000+ $ uri = new URI ($ expected );
1001+
1002+ $ this ->assertSame ($ expected , (string ) $ uri );
1003+ }
9881004}
You can’t perform that action at this time.
0 commit comments