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

Commit

Permalink
Merge branch 'master' of git://git.zendframework.com/zf
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 3 deletions.
Empty file modified src/Exception.php
100644 → 100755
Empty file.
Empty file modified src/Exception/InvalidArgumentException.php
100644 → 100755
Empty file.
Empty file modified src/Exception/InvalidUriException.php
100644 → 100755
Empty file.
Empty file modified src/Exception/InvalidUriPartException.php
100644 → 100755
Empty file.
Empty file modified src/Exception/InvalidUriTypeException.php
100644 → 100755
Empty file.
Empty file modified src/File.php
100644 → 100755
Empty file.
18 changes: 18 additions & 0 deletions src/Http.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,22 @@ protected function parseUserInfo()
$this->setUser($user);
$this->setPassword($password);
}

/**
* Return the URI port
*
* If no port is set, will return the default port according to the scheme
*
* @return integer
* @see Zend\Uri\Uri::getPort()
*/
public function getPort()
{
if (empty($this->port)) {
if (array_key_exists($this->scheme, self::$defaultPorts)) {
return self::$defaultPorts[$this->scheme];
}
}
return $this->port;
}
}
Empty file modified src/Mailto.php
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions src/Uri.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public function parse($uri)
$port = substr($authority, $colonPos + 1);
if ($port) {
$this->setPort((int) $port);
}
}
$authority = substr($authority, 0, $colonPos);
}

Expand Down Expand Up @@ -1063,7 +1063,7 @@ public static function removePathDotSegments($path)
*/
public static function merge($baseUri, $relativeUri)
{
$uri = new self($relativeUri);
$uri = new static($relativeUri);
return $uri->resolve($baseUri);
}

Expand Down
2 changes: 1 addition & 1 deletion src/UriFactory.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ abstract class UriFactory
static public function registerScheme($scheme, $class)
{
$scheme = strtolower($scheme);
static::$_schemeClasses[$scheme] = $class;
static::$schemeClasses[$scheme] = $class;
}

/**
Expand Down
27 changes: 27 additions & 0 deletions test/HttpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,5 +199,32 @@ public function testUserInfoCanOmitPassword()
$this->assertEquals('example.com', $uri->getHost());
}

public function testGetPortReturnsDefaultPortHttp()
{
$uri = new HttpUri('http://www.example.com/');
$this->assertEquals(80, $uri->getPort());
}

public function testGetPortReturnsDefaultPortHttps()
{
$uri = new HttpUri('https://www.example.com/');
$this->assertEquals(443, $uri->getPort());
}

public function testGetPortDoesntModifyUrlHttp()
{
$origUri = 'http://www.example.com/foo';
$uri = new HttpUri($origUri);
$uri->getPort();
$this->assertEquals($origUri, $uri->toString());
}

public function testGetPortDoesntModifyUrlHttps()
{
$origUri = 'https://www.example.com/foo';
$uri = new HttpUri($origUri);
$uri->getPort();
$this->assertEquals($origUri, $uri->toString());
}
}

0 comments on commit 2186cf3

Please sign in to comment.