Skip to content

Commit cd4e8da

Browse files
committed
Fix extra trailing slash when forceGlobalSecureRequests is enabled
1 parent 5d8dd65 commit cd4e8da

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

system/HTTP/URI.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ public static function createURIString(string $scheme = null, string $authority
603603

604604
if ($path !== '')
605605
{
606-
$uri .= substr($uri, -1, 1) !== '/' ? '/' . ltrim($path, '/') : $path;
606+
$uri .= substr($uri, -1, 1) !== '/' ? '/' . ltrim($path, '/') : ltrim($path, '/');
607607
}
608608

609609
if ($query)

tests/system/HTTP/URITest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public function testEmptyUri()
155155
$this->assertEquals('http://' . $url, (string) $uri);
156156
$url = '/';
157157
$uri = new URI($url);
158-
$this->assertEquals('http://' . $url, (string) $uri);
158+
$this->assertEquals('http://', (string) $uri);
159159
}
160160

161161
//--------------------------------------------------------------------
@@ -970,4 +970,12 @@ public function testSetURISilent()
970970
$this->assertTrue(true);
971971
}
972972

973+
public function testCreateURIString()
974+
{
975+
$expected = 'https://example.com/';
976+
$uri = URI::createURIString('https', 'example.com/', '/');
977+
978+
$this->assertEquals($expected, $uri);
979+
}
980+
973981
}

0 commit comments

Comments
 (0)