Skip to content

Commit

Permalink
fix: handing fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Feb 17, 2023
1 parent df5bf35 commit 2a0e22c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions system/HTTP/SiteURI.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public function __construct(

// Set routePath
$parts = explode('?', $relativePath);
$parts = explode('#', $parts[0]);
$routePath = $parts[0];
$this->setRoutePath($routePath);
}
Expand Down
24 changes: 24 additions & 0 deletions tests/system/HTTP/SiteURITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,30 @@ public function testConstructorRelativePathWithQuery()
$this->assertSame('foo=1&bar=2', $uri->getQuery());
}

public function testConstructorRelativePathWithFragment()
{
$config = new App();

$uri = new SiteURI($config, 'one/two#sec1');

$this->assertSame('http://example.com/index.php/one/two#sec1', (string) $uri);
$this->assertSame('/index.php/one/two', $uri->getPath());
$this->assertSame('', $uri->getQuery());
$this->assertSame('sec1', $uri->getFragment());
}

public function testConstructorRelativePathWithQueryAndFragment()
{
$config = new App();

$uri = new SiteURI($config, 'one/two?foo=1&bar=2#sec1');

$this->assertSame('http://example.com/index.php/one/two?foo=1&bar=2#sec1', (string) $uri);
$this->assertSame('/index.php/one/two', $uri->getPath());
$this->assertSame('foo=1&bar=2', $uri->getQuery());
$this->assertSame('sec1', $uri->getFragment());
}

public function testConstructorHost()
{
$config = new App();
Expand Down

0 comments on commit 2a0e22c

Please sign in to comment.