zendframework / zend-uri

Uri component from Zend Framework
BSD 3-Clause "New" or "Revised" License
117 stars 24 forks source link

Host contain a colon when port is empty #33

Closed linkuha closed 5 years ago

linkuha commented 5 years ago

i think in this case we have technically valid url, parse_url function also correct parses host

Example:

$source_uri = 'http://example.com:/';
echo 'parse_url: ';
var_dump(parse_url($source_uri));

$uri = new \Zend\Uri\Http($source_uri);
$tmp = [
    'scheme' => $uri->getScheme(),
    'user' => $uri->getUserInfo(),
    'host' => $uri->getHost(),
    'port' => $uri->getPort(),
    'path' => $uri->getPath(),
    'query' => $uri->getQuery(),
    'fragment' => $uri->getFragment(),
];
echo "\nzend-uri: ";
var_dump($tmp);

result output:

parse_url:
array (size=3)
      'scheme' => string 'http' (length=4)
      'host' => string 'example.com' (length=11)
      'path' => string '/' (length=1)
zend-uri:
array (size=7)
      'scheme' => string 'http' (length=4)
      'user' => null
      'host' => string 'example.com:' (length=12)
      'port' => int 80
      'path' => string '/' (length=1)
      'query' => null
      'fragment' => null