Skip to content

Commit 64ccca9

Browse files
Encode URIs according to RFC 3986
1 parent a27650b commit 64ccca9

File tree

2 files changed

+4
-24
lines changed

2 files changed

+4
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CHANGE LOG
77
* Use PSR-7, PSR-17 and PSR-18 only
88
* Update against latest API spec
99
* Refactored exceptions and internals
10+
* Encode URIs according to RFC 3986
1011

1112

1213
## V2.1.5 (29/06/2020)

src/HttpClient/Util/UriBuilder.php

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@
2424
*/
2525
final class UriBuilder
2626
{
27-
/**
28-
* The URI part separator.
29-
*
30-
* @var string
31-
*/
32-
private const URI_SEPARATOR = '/';
33-
3427
/**
3528
* Build a URI from the given parts.
3629
*
@@ -45,10 +38,10 @@ public static function build(string ...$parts)
4538
throw new ValueError(sprintf('%s::buildUri(): Argument #%d ($parts) must non-empty', self::class, $index + 1));
4639
}
4740

48-
$parts[$index] = self::encodePart($part);
41+
$parts[$index] = rawurlencode($part);
4942
}
5043

51-
return implode(self::URI_SEPARATOR, $parts);
44+
return implode('/', $parts);
5245
}
5346

5447
/**
@@ -60,20 +53,6 @@ public static function build(string ...$parts)
6053
*/
6154
public static function appendSeparator(string $uri)
6255
{
63-
return sprintf('%s%s', $uri, self::URI_SEPARATOR);
64-
}
65-
66-
/**
67-
* Encode the given part for a URI.
68-
*
69-
* @param string $part
70-
*
71-
* @return string
72-
*/
73-
private static function encodePart(string $part)
74-
{
75-
$part = rawurlencode($part);
76-
77-
return str_replace('.', '%2E', $part);
56+
return sprintf('%s%s', $uri, '/');
7857
}
7958
}

0 commit comments

Comments
 (0)