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

make host lowercase #29

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,10 @@ public function setHost($host)
), Exception\InvalidUriPartException::INVALID_HOSTNAME);
}

if ($host !== null) {
$host = strtolower($host);
}

$this->host = $host;
return $this;
}
Expand Down
10 changes: 5 additions & 5 deletions test/UriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public function testSetGetValidHost($host)
{
$uri = new Uri;
$uri->setHost($host);
$this->assertEquals($host, $uri->getHost());
$this->assertEquals(strtolower($host), $uri->getHost());
}

/**
Expand Down Expand Up @@ -821,12 +821,12 @@ public function validUriStringProvider()
['mailto:bob@example.com'],
['bob@example.com'],
['http://a_.!~*\'(-)n0123Di%25%26:pass;:&=+$,word@www.zend.com'],
['http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html'],
['http://[1080::8:800:200C:417A]/foo'],
['http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]:80/index.html'],
['http://[1080::8:800:200c:417a]/foo'],
['http://[::192.9.5.5]/ipng'],
['http://[::FFFF:129.144.52.38]:80/index.html'],
['http://[::ffff:129.144.52.38]:80/index.html'],
['http://[2620:0:1cfe:face:b00c::3]/'],
['http://[2010:836B:4179::836B:4179]'],
['http://[2010:836b:4179::836b:4179]'],
['http'],
['www.example.org:80'],
['www.example.org'],
Expand Down