diff --git a/system/HTTP/URI.php b/system/HTTP/URI.php index fc66654fda6c..497f13781330 100644 --- a/system/HTTP/URI.php +++ b/system/HTTP/URI.php @@ -1056,7 +1056,7 @@ protected function mergePaths(URI $base, URI $reference) { if ( ! empty($base->getAuthority()) && empty($base->getPath())) { - return '/' . ltrim($base->getPath(), '/ '); + return '/' . ltrim($reference->getPath(), '/ '); } $path = explode('/', $base->getPath()); diff --git a/tests/_support/Config/MockAppConfig.php b/tests/_support/Config/MockAppConfig.php index 96d4d81f6d0e..6d01e02e2567 100644 --- a/tests/_support/Config/MockAppConfig.php +++ b/tests/_support/Config/MockAppConfig.php @@ -2,7 +2,7 @@ class MockAppConfig { - public $baseURL = ''; + public $baseURL = 'http://example.com'; public $uriProtocol = 'REQUEST_URI'; diff --git a/tests/system/HTTP/IncomingRequestTest.php b/tests/system/HTTP/IncomingRequestTest.php index ff8622d5239d..b931fbc56ec1 100644 --- a/tests/system/HTTP/IncomingRequestTest.php +++ b/tests/system/HTTP/IncomingRequestTest.php @@ -369,6 +369,7 @@ public function testNegotiatesLocale() $config = new App(); $config->negotiateLocale = true; $config->supportedLocales = ['en', 'es']; + $config->baseURL = 'http://example.com'; $request = new IncomingRequest($config, new URI()); @@ -387,7 +388,10 @@ public function testCanGrabGetRawJSON() 'message' => 'ok' ]; - $request = new IncomingRequest(new App(), new URI(), $json); + $config = new App(); + $config->baseURL = 'http://example.com'; + + $request = new IncomingRequest($config, new URI(), $json); $this->assertEquals($expected, $request->getJSON(true)); } @@ -403,7 +407,11 @@ public function testCanGrabGetRawInput() 'role' => 'administrator', 'usepass' => 0 ]; - $request = new IncomingRequest(new App(), new URI(), $rawstring); + + $config = new App(); + $config->baseURL = 'http://example.com'; + + $request = new IncomingRequest($config, new URI(), $rawstring); $this->assertEquals($expected, $request->getRawInput()); } diff --git a/tests/system/Helpers/HTMLHelperTest.php b/tests/system/Helpers/HTMLHelperTest.php index 26e44c835dbb..b174e19a5388 100755 --- a/tests/system/Helpers/HTMLHelperTest.php +++ b/tests/system/Helpers/HTMLHelperTest.php @@ -180,7 +180,7 @@ public function testDocType() public function testVideo() { $expected = << + @@ -215,10 +215,10 @@ public function testVideo() $expected = << - - - - + + + + Your browser does not support the video tag. @@ -248,8 +248,8 @@ public function testAudio() { $expected = << - - + + Your browser does not support the audio tag. @@ -276,7 +276,7 @@ public function testAudio() public function testEmbed() { $expected = << + EOH; @@ -287,7 +287,7 @@ public function testEmbed() public function testObject() { $expected = << + EOH; @@ -301,7 +301,7 @@ public function testObject() $this->assertEquals($expected, $object); $expected = << + diff --git a/tests/system/Helpers/URLHelperTest.php b/tests/system/Helpers/URLHelperTest.php index da7be491f82e..1133c0c5a03d 100644 --- a/tests/system/Helpers/URLHelperTest.php +++ b/tests/system/Helpers/URLHelperTest.php @@ -28,7 +28,7 @@ public function testSiteURLBasics() $_SERVER['REQUEST_URI'] = '/'; $config = new App(); - $config->baseURL = ''; + $config->baseURL = 'http://example.com'; $config->indexPage = 'index.php'; $request = Services::request($config); $request->uri = new URI('http://example.com/'); @@ -45,7 +45,7 @@ public function testSiteURLHTTPS() $_SERVER['HTTPS'] = 'on'; $config = new App(); - $config->baseURL = ''; + $config->baseURL = 'http://example.com'; $config->indexPage = 'index.php'; $request = Services::request($config); $request->uri = new URI('http://example.com/'); @@ -61,7 +61,7 @@ public function testSiteURLNoIndex() $_SERVER['REQUEST_URI'] = '/'; $config = new App(); - $config->baseURL = ''; + $config->baseURL = 'http://example.com'; $config->indexPage = ''; $request = Services::request($config); $request->uri = new URI('http://example.com/'); @@ -77,7 +77,7 @@ public function testSiteURLDifferentIndex() $_SERVER['REQUEST_URI'] = '/'; $config = new App(); - $config->baseURL = ''; + $config->baseURL = 'http://example.com'; $config->indexPage = 'banana.php'; $request = Services::request($config); $request->uri = new URI('http://example.com/'); @@ -93,7 +93,7 @@ public function testSiteURLNoIndexButPath() $_SERVER['REQUEST_URI'] = '/'; $config = new App(); - $config->baseURL = ''; + $config->baseURL = 'http://example.com'; $config->indexPage = ''; $request = Services::request($config); $request->uri = new URI('http://example.com/'); @@ -109,7 +109,7 @@ public function testSiteURLAttachesPath() $_SERVER['REQUEST_URI'] = '/'; $config = new App(); - $config->baseURL = ''; + $config->baseURL = 'http://example.com'; $config->indexPage = 'index.php'; $request = Services::request($config); $request->uri = new URI('http://example.com/'); @@ -125,7 +125,7 @@ public function testSiteURLAttachesScheme() $_SERVER['REQUEST_URI'] = '/'; $config = new App(); - $config->baseURL = ''; + $config->baseURL = 'http://example.com'; $config->indexPage = 'index.php'; $request = Services::request($config); $request->uri = new URI('http://example.com/'); @@ -141,7 +141,7 @@ public function testSiteURLExample() $_SERVER['REQUEST_URI'] = '/'; $config = new App(); - $config->baseURL = ''; + $config->baseURL = 'http://example.com'; $config->indexPage = 'index.php'; $request = Services::request($config); $request->uri = new URI('http://example.com/'); @@ -157,7 +157,7 @@ public function testSiteURLSegments() $_SERVER['REQUEST_URI'] = '/'; $config = new App(); - $config->baseURL = ''; + $config->baseURL = 'http://example.com'; $config->indexPage = 'index.php'; $request = Services::request($config); $request->uri = new URI('http://example.com/'); @@ -198,7 +198,7 @@ public function testSiteURLWithSegmentsAgain() // Since we're on a CLI, we must provide our own URI $config = new App(); - $config->baseURL = ''; + $config->baseURL = 'http://example.com'; $request = Services::request($config, false); $request->uri = new URI('http://example.com/test/page'); @@ -218,7 +218,7 @@ public function testBaseURLBasics() $_SERVER['HTTP_HOST'] = 'example.com'; $_SERVER['REQUEST_URI'] = '/'; - $this->assertEquals('http://example.com/', base_url()); + $this->assertEquals('http://example.com', base_url()); } public function testBaseURLAttachesPath() @@ -312,13 +312,13 @@ public function testBaseURLWithSegmentsAgain() // Since we're on a CLI, we must provide our own URI $config = new App(); - $config->baseURL = ''; + $config->baseURL = 'http://example.com'; $request = Services::request($config, false); $request->uri = new URI('http://example.com/test/page'); Services::injectMock('request', $request); - $this->assertEquals('http://example.com/', base_url()); + $this->assertEquals('http://example.com', base_url()); $this->assertEquals('http://example.com/profile', base_url('profile')); } @@ -433,7 +433,7 @@ public function testUriString() $_SERVER['REQUEST_URI'] = '/'; $config = new App(); - $config->baseURL = ''; + $config->baseURL = 'http://example.com'; $config->indexPage = 'index.php'; $request = Services::request($config); $request->uri = new URI('http://example.com/'); @@ -451,7 +451,7 @@ public function testUriStringExample() $_SERVER['REQUEST_URI'] = '/assets/image.jpg'; $config = new App(); - $config->baseURL = ''; + $config->baseURL = 'http://example.com'; $config->indexPage = 'index.php'; $request = Services::request($config); $request->uri = new URI('http://example.com/assets/image.jpg'); @@ -468,7 +468,7 @@ public function testUriStringExample() public function testIndexPage() { $config = new App(); - $config->baseURL = ''; + $config->baseURL = 'http://example.com'; $config->indexPage = 'index.php'; $request = Services::request($config); $request->uri = new URI('http://example.com/'); @@ -481,7 +481,7 @@ public function testIndexPage() public function testIndexPageAlt() { $config = new App(); - $config->baseURL = ''; + $config->baseURL = 'http://example.com'; $config->indexPage = 'banana.php'; $request = Services::request($config); $request->uri = new URI('http://example.com/'); @@ -516,7 +516,7 @@ public function testAnchor($expected = '', $uri = '', $title = '', $attributes = $_SERVER['REQUEST_URI'] = '/'; $config = new App(); - $config->baseURL = ''; + $config->baseURL = 'http://example.com'; $config->indexPage = 'index.php'; $request = Services::request($config); $request->uri = new URI('http://example.com/'); @@ -547,7 +547,7 @@ public function testAnchorNoindex($expected = '', $uri = '', $title = '', $attri $_SERVER['REQUEST_URI'] = '/'; $config = new App(); - $config->baseURL = ''; + $config->baseURL = 'http://example.com'; $config->indexPage = ''; $request = Services::request($config); $request->uri = new URI('http://example.com/'); @@ -577,7 +577,7 @@ public function testAnchorTargetted($expected = '', $uri = '', $title = '', $att $_SERVER['REQUEST_URI'] = '/'; $config = new App(); - $config->baseURL = ''; + $config->baseURL = 'http://example.com'; $config->indexPage = ''; $request = Services::request($config); $request->uri = new URI('http://example.com/'); @@ -605,7 +605,7 @@ public function testAnchorExamples($expected = '', $uri = '', $title = '', $attr $_SERVER['REQUEST_URI'] = '/'; $config = new App(); - $config->baseURL = ''; + $config->baseURL = 'http://example.com'; $config->indexPage = 'index.php'; $request = Services::request($config); $request->uri = new URI('http://example.com/'); @@ -651,7 +651,7 @@ public function testAnchorPopup($expected = '', $uri = '', $title = '', $attribu $_SERVER['REQUEST_URI'] = '/'; $config = new App(); - $config->baseURL = ''; + $config->baseURL = 'http://example.com'; $config->indexPage = 'index.php'; $request = Services::request($config); $request->uri = new URI('http://example.com/'); @@ -681,7 +681,7 @@ public function testMailto($expected = '', $email, $title = '', $attributes = '' $_SERVER['REQUEST_URI'] = '/'; $config = new App(); - $config->baseURL = ''; + $config->baseURL = 'http://example.com'; $config->indexPage = 'index.php'; $request = Services::request($config); $request->uri = new URI('http://example.com/'); @@ -715,7 +715,7 @@ public function testSafeMailto($expected = '', $email, $title = '', $attributes $_SERVER['REQUEST_URI'] = '/'; $config = new App(); - $config->baseURL = ''; + $config->baseURL = 'http://example.com'; $config->indexPage = 'index.php'; $request = Services::request($config); $request->uri = new URI('http://example.com/');