Fixes the issue with trailing slashes and the comparison in GlobalSettings and updated unit tests

to support the fix.
This commit is contained in:
Shannon Deminick
2012-09-11 05:27:39 +07:00
parent 37969909ca
commit d5ca5e32b4
3 changed files with 13 additions and 4 deletions

View File

@@ -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);

View File

@@ -8,6 +8,13 @@ using umbraco.interfaces;
namespace Umbraco.Tests
{
[TestFixture]
public class GlobalSettingsTests
{
}
[TestFixture]
public class ActionsResolverTests
{

View File

@@ -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);