Skip to content

Commit

Permalink
fix: Fixed an issue where a trailing slash would be added to a pagina…
Browse files Browse the repository at this point in the history
…ted URL that uses URL parameters and `addTrailingSlashesToUrls` was `true` in the General config ([#1401](#1401))
  • Loading branch information
khalwat committed Feb 21, 2024
1 parent 2e33c68 commit 2a90464
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/helpers/UrlHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static function siteUrl(string $path = '', $params = null, string $scheme
$url = self::mergeUrlWithPath($siteUrl, $path);
// Handle trailing slashes properly for generated URLs
$generalConfig = Craft::$app->getConfig()->getGeneral();
if ($generalConfig->addTrailingSlashesToUrls && !preg_match('/\.[^\/]+$/', $url)) {
if ($generalConfig->addTrailingSlashesToUrls && !preg_match('/(.+\?.*)|(\.[^\/]+$)/', $url)) {
$url = rtrim($url, '/') . '/';
}
if (!$generalConfig->addTrailingSlashesToUrls) {
Expand Down Expand Up @@ -151,7 +151,7 @@ public static function absoluteUrlWithProtocol($url): string

// Handle trailing slashes properly for generated URLs
$generalConfig = Craft::$app->getConfig()->getGeneral();
if ($generalConfig->addTrailingSlashesToUrls && !preg_match('/\.[^\/]+$/', $url)) {
if ($generalConfig->addTrailingSlashesToUrls && !preg_match('/(.+\?.*)|(\.[^\/]+$)/', $url)) {
$url = rtrim($url, '/') . '/';
}
if (!$generalConfig->addTrailingSlashesToUrls) {
Expand Down

0 comments on commit 2a90464

Please sign in to comment.