Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for force_https() function #3292

Merged
merged 2 commits into from
Jul 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions system/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,12 @@ function force_https(int $duration = 31536000, RequestInterface $request = null,

$baseURL = config(App::class)->baseURL;

// If we already use 'https' then return immediately
if (strpos($baseURL, 'https://') === 0)
{
return;
}

if (strpos($baseURL, 'http://') === 0)
{
$baseURL = (string) substr($baseURL, strlen('http://'));
Expand Down
2 changes: 1 addition & 1 deletion system/HTTP/URI.php
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ public static function createURIString(string $scheme = null, string $authority

if ($path !== '')
{
$uri .= substr($uri, -1, 1) !== '/' ? '/' . ltrim($path, '/') : $path;
$uri .= substr($uri, -1, 1) !== '/' ? '/' . ltrim($path, '/') : ltrim($path, '/');
}

if ($query)
Expand Down
10 changes: 9 additions & 1 deletion tests/system/HTTP/URITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function testEmptyUri()
$this->assertEquals('http://' . $url, (string) $uri);
$url = '/';
$uri = new URI($url);
$this->assertEquals('http://' . $url, (string) $uri);
$this->assertEquals('http://', (string) $uri);
}

//--------------------------------------------------------------------
Expand Down Expand Up @@ -970,4 +970,12 @@ public function testSetURISilent()
$this->assertTrue(true);
}

public function testCreateURIString()
{
$expected = 'https://example.com/';
$uri = URI::createURIString('https', 'example.com/', '/');

$this->assertEquals($expected, $uri);
}

}