Skip to content

Commit

Permalink
fix: Don’t strip trailing / from incoming URLs after normalization ([#…
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Sep 24, 2024
1 parent b520484 commit 7af2fad
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/helpers/UrlHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public static function stripSitePathPrefix($path): string
$baseSiteUrl = '';
}
$sitePath = parse_url($baseSiteUrl, PHP_URL_PATH);
$addSlash = str_ends_with($path, '/');
if (!empty($sitePath)) {
// Normalizes a URI path by trimming leading/ trailing slashes and removing double slashes
$sitePath = '/' . preg_replace('/\/\/+/', '/', trim($sitePath, '/'));
Expand All @@ -71,6 +72,7 @@ public static function stripSitePathPrefix($path): string
$path = substr($path, strlen($sitePath));
$path = '/' . preg_replace('/\/\/+/', '/', trim($path, '/'));
}
$path = $addSlash ? $path . '/' : $path;

return $path;
}
Expand Down

0 comments on commit 7af2fad

Please sign in to comment.