|
12 | 12 |
|
13 | 13 | use InvalidArgumentException; |
14 | 14 | use function array_map, array_merge, call_user_func_array, explode, implode, is_array, is_bool, |
15 | | - is_iterable, is_numeric, is_scalar, is_string, parse_url, preg_match, preg_replace_callback, |
16 | | - rawurldecode, rawurlencode, sort, str_replace, trim, uksort, urlencode; |
| 15 | + is_iterable, is_numeric, is_scalar, is_string, rawurldecode, rawurlencode, sort, str_replace, |
| 16 | + trim, uksort; |
17 | 17 | use const PHP_QUERY_RFC1738, PHP_QUERY_RFC3986, SORT_STRING; |
18 | 18 |
|
19 | 19 | /** |
@@ -162,7 +162,7 @@ public static function build(array $params, int $encoding = null, string $delimi |
162 | 162 | * Merges additional query parameters into an existing query string |
163 | 163 | */ |
164 | 164 | public static function merge(string $uri, array $query):string{ |
165 | | - $querypart = (self::parseUrl($uri)['query'] ?? ''); |
| 165 | + $querypart = (UriUtil::parseUrl($uri)['query'] ?? ''); |
166 | 166 | $params = array_merge(self::parse($querypart), $query); |
167 | 167 | $requestURI = explode('?', $uri)[0]; |
168 | 168 |
|
@@ -221,41 +221,6 @@ public static function parse(string $querystring, int $urlEncoding = null):array |
221 | 221 | return $result; |
222 | 222 | } |
223 | 223 |
|
224 | | - /** |
225 | | - * UTF-8 aware \parse_url() replacement. |
226 | | - * |
227 | | - * The internal function produces broken output for non ASCII domain names |
228 | | - * (IDN) when used with locales other than "C". |
229 | | - * |
230 | | - * On the other hand, cURL understands IDN correctly only when UTF-8 locale |
231 | | - * is configured ("C.UTF-8", "en_US.UTF-8", etc.). |
232 | | - * |
233 | | - * @see https://bugs.php.net/bug.php?id=52923 |
234 | | - * @see https://www.php.net/manual/en/function.parse-url.php#114817 |
235 | | - * @see https://curl.haxx.se/libcurl/c/CURLOPT_URL.html#ENCODING |
236 | | - * |
237 | | - * @link https://github.com/guzzle/psr7/blob/c0dcda9f54d145bd4d062a6d15f54931a67732f9/src/Uri.php#L89-L130 |
238 | | - */ |
239 | | - public static function parseUrl(string $url):?array{ |
240 | | - // If IPv6 |
241 | | - $prefix = ''; |
242 | | - /** @noinspection RegExpRedundantEscape */ |
243 | | - if(preg_match('%^(.*://\[[0-9:a-f]+\])(.*?)$%', $url, $matches)){ |
244 | | - /** @var array{0:string, 1:string, 2:string} $matches */ |
245 | | - $prefix = $matches[1]; |
246 | | - $url = $matches[2]; |
247 | | - } |
248 | | - |
249 | | - $encodedUrl = preg_replace_callback('%[^:/@?&=#]+%usD', fn($matches) => urlencode($matches[0]), $url); |
250 | | - $result = parse_url($prefix.$encodedUrl); |
251 | | - |
252 | | - if($result === false){ |
253 | | - return null; |
254 | | - } |
255 | | - |
256 | | - return array_map('urldecode', $result); |
257 | | - } |
258 | | - |
259 | 224 | /** |
260 | 225 | * Recursive rawurlencode |
261 | 226 | * |
|
0 commit comments