From 76a8888cdcd5cd7467f2deb0a2b6dca401decb86 Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Tue, 10 Oct 2017 11:33:36 -0400 Subject: [PATCH] More intelligent handling of `addTrailingSlashesToUrls` Signed-off-by: Andrew Welch --- CHANGELOG.md | 4 ++++ SeomaticPlugin.php | 2 +- releases.json | 8 ++++++++ services/SeomaticService.php | 16 +++++++++------- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da2025b..9433a8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # SEOmatic Changelog +## 1.1.54 - 2017.10.10 +### Changed +* More intelligent handling of `addTrailingSlashesToUrls` + ## 1.1.53 - 2017.10.06 ### Changed * Fixed a regression with certain types of localized sites diff --git a/SeomaticPlugin.php b/SeomaticPlugin.php index f3ea50a..453134a 100755 --- a/SeomaticPlugin.php +++ b/SeomaticPlugin.php @@ -26,7 +26,7 @@ public function getReleaseFeedUrl() public function getVersion() { - return '1.1.53'; + return '1.1.54'; } public function getSchemaVersion() diff --git a/releases.json b/releases.json index 60852e0..715d046 100644 --- a/releases.json +++ b/releases.json @@ -1,4 +1,12 @@ [ + { + "version": "1.1.54", + "downloadUrl": "https://github.com/nystudio107/seomatic/archive/master.zip", + "date": "2017-10-10T11:00:00-11:00", + "notes": [ + "[Improved] More intelligent handling of `addTrailingSlashesToUrls`" + ] + }, { "version": "1.1.53", "downloadUrl": "https://github.com/nystudio107/seomatic/archive/master.zip", diff --git a/services/SeomaticService.php b/services/SeomaticService.php index 7d3c9f4..10982e3 100644 --- a/services/SeomaticService.php +++ b/services/SeomaticService.php @@ -3114,13 +3114,15 @@ public function getFullyQualifiedUrl($url) $result = UrlHelper::getSiteUrl($url, null, null, craft()->language); } } - // Add a trailing / if `addTrailingSlashesToUrls` is set, but only if there's one extension - if (craft()->config->get('addTrailingSlashesToUrls')) { - $path = parse_url($result, PHP_URL_PATH); - $pathExtension = pathinfo($path,PATHINFO_EXTENSION); - if (empty($pathExtension)) - $result = rtrim($result, '/') . '/'; - } + } + + $result = rtrim($result, '/'); + // Add a trailing / if `addTrailingSlashesToUrls` is set, but only if there's one extension + if (craft()->config->get('addTrailingSlashesToUrls')) { + $path = parse_url($result, PHP_URL_PATH); + $pathExtension = pathinfo($path,PATHINFO_EXTENSION); + if (empty($pathExtension)) + $result = rtrim($result, '/') . '/'; } return $result;