Skip to content

Commit 3588017

Browse files
committed
Only produce lowercase scheme names from Url::__toString()
Fixes #51.
1 parent a93f65d commit 3588017

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/Pdp/Uri/Url.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function __toString()
121121
$url = null;
122122

123123
if ($this->scheme) {
124-
$url .= $this->scheme . '://';
124+
$url .= mb_strtolower($this->scheme, 'UTF-8') . '://';
125125
}
126126

127127
if ($this->user) {

tests/src/Pdp/Uri/UrlTest.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,31 @@ public function testIdnToAscii()
154154
* Scheme should not be URL encoded
155155
*
156156
* @group issue46
157+
* @group issue51
157158
*
158159
* @see https://tools.ietf.org/html/rfc3986#section-3.1
159160
*/
160-
public function testToStringDoesNotUrlEncodeScheme()
161+
public function test__toStringDoesNotUrlEncodeScheme()
161162
{
162163
// The '+' should not be URL encoded when output to string
163164
$spec = 'fake-scheme+RFC-3986.compliant://www.graphstory.com';
165+
$expected = 'fake-scheme+rfc-3986.compliant://www.graphstory.com';
164166
$url = $this->parser->parseUrl($spec);
165-
$this->assertEquals($spec, $url->__toString());
167+
$this->assertEquals($expected, $url->__toString());
168+
}
169+
170+
/**
171+
* Scheme should be output in lowercase regardless of case of original arg
172+
*
173+
* @group issue51
174+
*
175+
* @see https://tools.ietf.org/html/rfc3986#section-3.1
176+
*/
177+
public function testSchemeAlwaysConvertedToLowerCasePerRFC3986()
178+
{
179+
$spec = 'HttPS://www.google.com';
180+
$expected = 'https://www.google.com';
181+
$url = $this->parser->parseUrl($spec);
182+
$this->assertEquals($expected, $url->__toString());
166183
}
167184
}

0 commit comments

Comments
 (0)