Skip to content

Commit 200dbf3

Browse files
committed
Changes encode according to RFC 3986 to support ~
1 parent 2c349ff commit 200dbf3

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/UrlHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function __construct($path, $params, $secret = null)
2424
private function getPath()
2525
{
2626
if(filter_var($this->path, FILTER_VALIDATE_URL)) {
27-
return urlencode($this->path);
27+
return rawurlencode($this->path);
2828
}
2929

3030
return ltrim($this->path, "/");

tests/src/UrlTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,17 @@ public function testToString()
8989
$this->assertEquals($expected, $url);
9090
}
9191

92+
public function testTildeURL()
93+
{
94+
$urlBuilder = $this->urlBuilder = new UrlBuilder('image.barnebys.sh');
95+
$urlBuilder->setPath('https://thumbs.ebaystatic.com/images/g/C~UAAOSwCaBboCgO/s-l140.jpg');
96+
97+
98+
$url = (string) $urlBuilder;
99+
$expected = 'https://image.barnebys.sh/https%3A%2F%2Fthumbs.ebaystatic.com%2Fimages%2Fg%2FC~UAAOSwCaBboCgO%2Fs-l140.jpg';
100+
101+
$this->assertEquals($expected, $url);
102+
}
103+
104+
92105
}

0 commit comments

Comments
 (0)