diff --git a/src/Umbraco.Tests/DocumentLookups/LookupByNiceUrlTests.cs b/src/Umbraco.Tests/DocumentLookups/LookupByNiceUrlTests.cs
index 054584ffa2..8ce81b88e0 100644
--- a/src/Umbraco.Tests/DocumentLookups/LookupByNiceUrlTests.cs
+++ b/src/Umbraco.Tests/DocumentLookups/LookupByNiceUrlTests.cs
@@ -1,4 +1,3 @@
-using System;
using System.Configuration;
using System.Linq;
using System.Web;
@@ -16,7 +15,6 @@ using umbraco.cms.businesslogic.template;
namespace Umbraco.Tests.DocumentLookups
{
-
[TestFixture, RequiresSTA]
public abstract class BaseTest
{
@@ -114,26 +112,11 @@ namespace Umbraco.Tests.DocumentLookups
public class LookupByNiceUrlTests : BaseTest
{
- //[TestCase("/default.aspx")]
- //public void Match_Document_By_Non_Directory_Url(string urlAsString)
- //{
- // var template = Template.MakeNew("test", new User(0));
- // var routingContext = GetRoutingContext(urlAsString, template);
- // var cleanUrl = routingContext.UmbracoContext.HttpContext.Request.Url;
- // var path = routingContext.UmbracoContext.RequestUrl.AbsolutePath.ToLower();
- // UmbracoModule.LegacyCleanUmbPageFromQueryString(ref cleanUrl, ref path);
-
- // var docRequest = new DocumentRequest(cleanUrl, routingContext);
-
- // var lookup = new LookupByNiceUrl();
- // var result = lookup.TrySetDocument(docRequest);
-
- // Assert.IsTrue(result);
- //}
-
[TestCase("/")]
+ [TestCase("/default.aspx")] //this one is actually rather important since this is the path that comes through when we are running in pre-IIS 7 for the root document '/' !
[TestCase("/Sub1")]
[TestCase("/sub1")]
+ [TestCase("/sub1.aspx")]
public void Match_Document_By_Directory_Url_Hide_Top_Level(string urlAsString)
{
var template = Template.MakeNew("test", new User(0));
@@ -150,13 +133,15 @@ namespace Umbraco.Tests.DocumentLookups
}
[TestCase("/")]
+ [TestCase("/default.aspx")] //this one is actually rather important since this is the path that comes through when we are running in pre-IIS 7 for the root document '/' !
[TestCase("/home/Sub1")]
[TestCase("/Home/Sub1")] //different cases
+ [TestCase("/home/Sub1.aspx")]
public void Match_Document_By_Directory_Url(string urlAsString)
{
var template = Template.MakeNew("test", new User(0));
var routingContext = GetRoutingContext(urlAsString, template);
- var url = routingContext.UmbracoContext.HttpContext.Request.Url;
+ var url = routingContext.UmbracoContext.UmbracoUrl;
var docRequest = new DocumentRequest(url, routingContext);
var lookup = new LookupByNiceUrl();
diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj
index 8720e5f083..44c73bbaf7 100644
--- a/src/Umbraco.Tests/Umbraco.Tests.csproj
+++ b/src/Umbraco.Tests/Umbraco.Tests.csproj
@@ -61,6 +61,7 @@
+
diff --git a/src/Umbraco.Tests/UriUtilityTests.cs b/src/Umbraco.Tests/UriUtilityTests.cs
new file mode 100644
index 0000000000..6605d22885
--- /dev/null
+++ b/src/Umbraco.Tests/UriUtilityTests.cs
@@ -0,0 +1,26 @@
+using System;
+using NUnit.Framework;
+using Umbraco.Web;
+
+namespace Umbraco.Tests
+{
+ [TestFixture]
+ public class UriUtilityTests
+ {
+
+ [TestCase("http://Localhost/", "http://localhost/")]
+ [TestCase("http://localhost/default.aspx", "http://localhost/")]
+ [TestCase("http://localhost/default.aspx?test=blah", "http://localhost/?test=blah")]
+ [TestCase("http://localhost/home/Sub1", "http://localhost/home/sub1")]
+ [TestCase("http://localhost/home/Sub1.aspx", "http://localhost/home/sub1")]
+ [TestCase("http://localhost/home/Sub1.aspx?test=blah", "http://localhost/home/sub1?test=blah")]
+ public void Uri_To_Umbraco(string url, string expected)
+ {
+ var uri = new Uri(url);
+ var expectedUri = new Uri(expected);
+ var result = UriUtility.UriToUmbraco(uri);
+
+ Assert.AreEqual(expectedUri.ToString(), result.ToString());
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Web/UmbracoModule.cs b/src/Umbraco.Web/UmbracoModule.cs
index d0c162c720..5317b644d6 100644
--- a/src/Umbraco.Web/UmbracoModule.cs
+++ b/src/Umbraco.Web/UmbracoModule.cs
@@ -72,8 +72,8 @@ namespace Umbraco.Web
//assign the routing context back to the umbraco context
umbracoContext.RoutingContext = routingContext;
- var uri = httpContext.Request.Url;
- var lpath = uri.AbsolutePath.ToLower();
+ var uri = umbracoContext.UmbracoUrl;
+ var lpath = umbracoContext.UmbracoUrl.AbsolutePath.ToLowerInvariant();
// legacy - no idea what this is
LegacyCleanUmbPageFromQueryString(ref uri, ref lpath);
@@ -348,6 +348,7 @@ namespace Umbraco.Web
// "Clean umbPage from querystring, caused by .NET 2.0 default Auth Controls"
// but really, at the moment I have no idea what this does, and why...
+ // SD: I also have no idea what this does, I've googled umbPage and really nothing shows up
internal static void LegacyCleanUmbPageFromQueryString(ref Uri uri, ref string lpath)
{
string receivedQuery = uri.Query;
diff --git a/src/Umbraco.Web/UriUtility.cs b/src/Umbraco.Web/UriUtility.cs
index 488a6f2df6..8368ab26ce 100644
--- a/src/Umbraco.Web/UriUtility.cs
+++ b/src/Umbraco.Web/UriUtility.cs
@@ -71,15 +71,19 @@ namespace Umbraco.Web
{
var path = uri.GetSafeAbsolutePath();
+ path = path.ToLower();
+
//we need to check if the path is /default.aspx because this will occur when using a
//web server pre IIS 7 when requesting the root document
//if this is the case we need to change it to '/'
-
- path = path.ToLower();
+ if (path.EndsWith("default.aspx", StringComparison.InvariantCultureIgnoreCase))
+ {
+ path = path.Substring(0, path.Length - "default.aspx".Length);
+ }
if (path != "/")
path = path.TrimEnd('/');
- if (path.EndsWith(".aspx"))
- path = path.Substring(0, path.Length - ".aspx".Length);
+ if (path.EndsWith(".aspx"))
+ path = path.Substring(0, path.Length - ".aspx".Length);
return uri.Rewrite(path);
}