From d5ca5e32b4301c6b7b8fe5ffd5d94f6c30340792 Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Tue, 11 Sep 2012 05:27:39 +0700 Subject: [PATCH] Fixes the issue with trailing slashes and the comparison in GlobalSettings and updated unit tests to support the fix. --- src/Umbraco.Core/Configuration/GlobalSettings.cs | 8 ++++---- src/Umbraco.Tests/ActionsResolverTests.cs | 7 +++++++ src/Umbraco.Tests/Routing/UmbracoModuleTests.cs | 2 ++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Core/Configuration/GlobalSettings.cs b/src/Umbraco.Core/Configuration/GlobalSettings.cs index ac4f7647ae..290f252db3 100644 --- a/src/Umbraco.Core/Configuration/GlobalSettings.cs +++ b/src/Umbraco.Core/Configuration/GlobalSettings.cs @@ -834,12 +834,12 @@ namespace Umbraco.Core.Configuration public int Compare(string part, string whole) { // let the default string comparer deal with null or when part is not smaller then whole - if (part == null || whole == null) + if (part == null || whole == null || part.Length >= whole.Length) return _stringComparer.Compare(part, whole); - //trim the end '/' of each - part = part.TrimEnd('/'); - whole = whole.TrimEnd('/'); + //ensure both have a / on the end + part = part.EndsWith("/") ? part : part + "/"; + whole = whole.EndsWith("/") ? whole : whole + "/"; if (part.Length >= whole.Length) return _stringComparer.Compare(part, whole); diff --git a/src/Umbraco.Tests/ActionsResolverTests.cs b/src/Umbraco.Tests/ActionsResolverTests.cs index 45eab01c35..3885d74808 100644 --- a/src/Umbraco.Tests/ActionsResolverTests.cs +++ b/src/Umbraco.Tests/ActionsResolverTests.cs @@ -8,6 +8,13 @@ using umbraco.interfaces; namespace Umbraco.Tests { + + [TestFixture] + public class GlobalSettingsTests + { + + } + [TestFixture] public class ActionsResolverTests { diff --git a/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs b/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs index 8c95076684..c855a82a46 100644 --- a/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs +++ b/src/Umbraco.Tests/Routing/UmbracoModuleTests.cs @@ -65,6 +65,8 @@ namespace Umbraco.Tests.Routing [TestCase("/base/somebasehandler", false)] [TestCase("/", true)] [TestCase("/home.aspx", true)] + [TestCase("/umbraco-test", true)] + [TestCase("/install-test", true)] public void Ensure_Request_Routable(string url, bool assert) { var httpContextFactory = new FakeHttpContextFactory(url);