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

Commit

Permalink
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Http extends Uri
/**
* @see Uri::$validHostTypes
*/
protected $validHostTypes = self::HOST_DNS_OR_IPV4_OR_IPV6;
protected $validHostTypes = self::HOST_DNS_OR_IPV4_OR_IPV6_OR_REGNAME;

/**
* User name as provided in authority of URI
Expand Down
7 changes: 4 additions & 3 deletions src/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Uri implements UriInterface
const HOST_DNS_OR_IPV4_OR_IPV6 = 0x0B; //01011
const HOST_DNS_OR_IPVANY = 0x0F; //01111
const HOST_REGNAME = 0x10; //10000
const HOST_DNS_OR_IPV4_OR_IPV6_OR_REGNAME = 0x13; //10011
const HOST_ALL = 0x1F; //11111

/**
Expand Down Expand Up @@ -359,17 +360,17 @@ public function toString()
}

if ($this->path) {
$uri .= self::encodePath($this->path);
$uri .= static::encodePath($this->path);
} elseif ($this->host && ($this->query || $this->fragment)) {
$uri .= '/';
}

if ($this->query) {
$uri .= "?" . self::encodeQueryFragment($this->query);
$uri .= "?" . static::encodeQueryFragment($this->query);
}

if ($this->fragment) {
$uri .= "#" . self::encodeQueryFragment($this->fragment);
$uri .= "#" . static::encodeQueryFragment($this->fragment);
}

return $uri;
Expand Down
6 changes: 6 additions & 0 deletions test/HttpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,10 @@ public function testGetPortDoesntModifyUrlHttps()
$uri->getPort();
$this->assertEquals($origUri, $uri->toString());
}

public function testValidHostTypesWithUnderScore()
{
$uri = new HttpUri('http://zf2_app.local');
$this->assertTrue($uri->isValid());
}
}

0 comments on commit 21286c5

Please sign in to comment.