diff --git a/src/Umbraco.Core/Routing/UriUtility.cs b/src/Umbraco.Core/Routing/UriUtility.cs index 96325d1289..43a36db101 100644 --- a/src/Umbraco.Core/Routing/UriUtility.cs +++ b/src/Umbraco.Core/Routing/UriUtility.cs @@ -55,9 +55,15 @@ namespace Umbraco.Web { if (virtualPath.InvariantStartsWith(_appPathPrefix) && (virtualPath.Length == _appPathPrefix.Length || virtualPath[_appPathPrefix.Length] == '/')) + { virtualPath = virtualPath.Substring(_appPathPrefix.Length); + } + if (virtualPath.Length == 0) + { virtualPath = "/"; + } + return virtualPath; } @@ -88,9 +94,8 @@ namespace Umbraco.Web // ie no virtual directory, no .aspx, lowercase... public Uri UriToUmbraco(Uri uri) { - // TODO: Ideally we do this witout so many string allocations, we can use - // techniques like StringSegment and Span. This is critical code that executes on every request. - // not really sure we need ToLower. + // TODO: This is critical code that executes on every request, we should + // look into if all of this is necessary? not really sure we need ToLower? // note: no need to decode uri here because we're returning a uri // so it will be re-encoded anyway diff --git a/src/Umbraco.Core/UriExtensions.cs b/src/Umbraco.Core/UriExtensions.cs index 53bf2d6d92..26580fab84 100644 --- a/src/Umbraco.Core/UriExtensions.cs +++ b/src/Umbraco.Core/UriExtensions.cs @@ -67,6 +67,8 @@ namespace Umbraco.Core // cannot get .AbsolutePath on relative uri (InvalidOperation) var s = uri.OriginalString; + + // TODO: Shouldn't this just use Uri.GetLeftPart? var posq = s.IndexOf("?", StringComparison.Ordinal); var posf = s.IndexOf("#", StringComparison.Ordinal); var pos = posq > 0 ? posq : (posf > 0 ? posf : 0);