Skip to content

Commit

Permalink
reworked to use the modified Uri::parseUrl(), plus better fix for mul…
Browse files Browse the repository at this point in the history
…ti slashes
  • Loading branch information
rhukster committed May 8, 2024
1 parent 51623ee commit c97a0ff
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions system/src/Grav/Common/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public function init()
$uri = $language->setActiveFromUri($uri);

// split the URL and params (and make sure that the path isn't seen as domain)
$bits = parse_url('http://domain.com' . $uri);
$bits = static::parseUrl('http://domain.com' . $uri);

//process fragment
if (isset($bits['fragment'])) {
Expand Down Expand Up @@ -265,6 +265,7 @@ public function paths($id = null)
return $this->paths;
}


/**
* Return route to the current URI. By default route doesn't include base path.
*
Expand Down Expand Up @@ -954,9 +955,7 @@ public static function parseUrl($url)
$grav = Grav::instance();

// Remove extra slash from streams, parse_url() doesn't like it.
if ($pos = strpos($url, ':///')) {
$url = substr_replace($url, '://', $pos, 4);
}
$url = preg_replace('/([^:])(\/{2,})/', '$1/', $url);

$encodedUrl = preg_replace_callback(
'%[^:/@?&=#]+%usD',
Expand Down

0 comments on commit c97a0ff

Please sign in to comment.