Skip to content

Commit a93f65d

Browse files
committed
Fix bug where scheme was being URL encoded
1 parent 8e11030 commit a93f65d

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
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 .= urlencode($this->scheme) . '://';
124+
$url .= $this->scheme . '://';
125125
}
126126

127127
if ($this->user) {

tests/src/Pdp/Uri/UrlTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,19 @@ public function testIdnToAscii()
149149

150150
$this->assertEquals($expected, $actual);
151151
}
152+
153+
/**
154+
* Scheme should not be URL encoded
155+
*
156+
* @group issue46
157+
*
158+
* @see https://tools.ietf.org/html/rfc3986#section-3.1
159+
*/
160+
public function testToStringDoesNotUrlEncodeScheme()
161+
{
162+
// The '+' should not be URL encoded when output to string
163+
$spec = 'fake-scheme+RFC-3986.compliant://www.graphstory.com';
164+
$url = $this->parser->parseUrl($spec);
165+
$this->assertEquals($spec, $url->__toString());
166+
}
152167
}

0 commit comments

Comments
 (0)