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 273d830 commit db60096
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(string $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(string $path): string
$path = substr($path, strlen($sitePath));
$path = '/' . preg_replace('/\/\/+/', '/', trim($path, '/'));
}
$path = $addSlash ? $path . '/' : $path;

return $path;
}
Expand Down

0 comments on commit db60096

Please sign in to comment.