From 0ee95e83a0baad63f42fc74a8a89e4c299f42e6f Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Tue, 24 Nov 2020 19:22:20 -0500 Subject: [PATCH 1/2] Fixes Issue with Trailing Slash --- CHANGELOG.md | 2 ++ .../MSFT_SPAlternateUrl/MSFT_SPAlternateUrl.psm1 | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64b7fad18..6b41a94f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- SPAlternateUrl + - Fixed issue where trailing '/' cause Url not to be recognized. - SPFarm - Switched from creating a Lock database to a Lock table in the TempDB. This to allow the use of precreated databases. diff --git a/SharePointDsc/DSCResources/MSFT_SPAlternateUrl/MSFT_SPAlternateUrl.psm1 b/SharePointDsc/DSCResources/MSFT_SPAlternateUrl/MSFT_SPAlternateUrl.psm1 index 946b8d81f..ec48787a7 100644 --- a/SharePointDsc/DSCResources/MSFT_SPAlternateUrl/MSFT_SPAlternateUrl.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPAlternateUrl/MSFT_SPAlternateUrl.psm1 @@ -168,6 +168,13 @@ function Set-TargetResource $aamForUrl = $webAppAams | Where-Object -FilterScript { $_.IncomingUrl -eq $params.Url } + if ($null -eq $aamForUrl -and $params.Url.ToString().EndsWith('/')) + { + $urlToFind = $params.Url.Remove($params.Url.Length - 1, 1) + $aamForUrl = $webAppAams | Where-Object -FilterScript { + $_.IncomingUrl -eq $urlToFind + } + } if ($null -eq $aamForUrl) { From 9dbb6028ab19b73147cb923a117ff66600d7e5cc Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Wed, 25 Nov 2020 08:05:31 -0500 Subject: [PATCH 2/2] Update MSFT_SPAlternateUrl.psm1 --- .../MSFT_SPAlternateUrl/MSFT_SPAlternateUrl.psm1 | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/SharePointDsc/DSCResources/MSFT_SPAlternateUrl/MSFT_SPAlternateUrl.psm1 b/SharePointDsc/DSCResources/MSFT_SPAlternateUrl/MSFT_SPAlternateUrl.psm1 index ec48787a7..a5755e0bb 100644 --- a/SharePointDsc/DSCResources/MSFT_SPAlternateUrl/MSFT_SPAlternateUrl.psm1 +++ b/SharePointDsc/DSCResources/MSFT_SPAlternateUrl/MSFT_SPAlternateUrl.psm1 @@ -166,14 +166,7 @@ function Set-TargetResource { # WebApp has one or more AAMs, check for URL $aamForUrl = $webAppAams | Where-Object -FilterScript { - $_.IncomingUrl -eq $params.Url - } - if ($null -eq $aamForUrl -and $params.Url.ToString().EndsWith('/')) - { - $urlToFind = $params.Url.Remove($params.Url.Length - 1, 1) - $aamForUrl = $webAppAams | Where-Object -FilterScript { - $_.IncomingUrl -eq $urlToFind - } + $_.IncomingUrl -eq $params.Url.TrimEnd('/') } if ($null -eq $aamForUrl)