mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 08:47:52 +00:00
Fixed url parsing issues
This commit is contained in:
@@ -134,7 +134,15 @@ class Uri
|
|||||||
*/
|
*/
|
||||||
public function parseUrl($url, $component = -1)
|
public function parseUrl($url, $component = -1)
|
||||||
{
|
{
|
||||||
$parts = parse_url(urlencode($url), $component);
|
$encodedUrl = preg_replace_callback(
|
||||||
|
'%[^:/@?&=#]+%u',
|
||||||
|
function ($matches) {
|
||||||
|
return urlencode($matches[0]);
|
||||||
|
},
|
||||||
|
$url
|
||||||
|
);
|
||||||
|
|
||||||
|
$parts = parse_url($encodedUrl, $component);
|
||||||
|
|
||||||
if ($parts === false) {
|
if ($parts === false) {
|
||||||
throw new \InvalidArgumentException('Malformed URL: ' . $url);
|
throw new \InvalidArgumentException('Malformed URL: ' . $url);
|
||||||
|
|||||||
Reference in New Issue
Block a user