Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/4288' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,20 @@ public function isAbsolute()
return ($this->scheme !== null);
}

/**
* Reset URI parts
*/
protected function reset()
{
$this->setScheme(null);
$this->setPort(null);
$this->setUserInfo(null);
$this->setHost(null);
$this->setPath(null);
$this->setFragment(null);
$this->setQuery(null);
}

/**
* Parse a URI string
*
Expand All @@ -261,6 +275,8 @@ public function isAbsolute()
*/
public function parse($uri)
{
$this->reset();

// Capture scheme
if (($scheme = self::parseScheme($uri)) !== null) {
$this->setScheme($scheme);
Expand Down
14 changes: 14 additions & 0 deletions test/UriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1335,4 +1335,18 @@ public function notStringInputProvider()
array(array('scheme' => 'http', 'host' => 'example.com'))
);
}

public function testParseTwice()
{
$uri = new Uri();
$uri->parse('http://user@example.com:1/absolute/url?query#fragment');
$uri->parse('/relative/url');
$this->assertNull($uri->getScheme());
$this->assertNull($uri->getHost());
$this->assertNull($uri->getUserInfo());
$this->assertNull($uri->getPort());
$this->assertNull($uri->getQuery());
$this->assertNull($uri->getFragment());
}

}

0 comments on commit c3abd2b

Please sign in to comment.