diff --git a/src/Umbraco.Core/IO/IOHelper.cs b/src/Umbraco.Core/IO/IOHelper.cs index 5ce851bdb4..2ee0463435 100644 --- a/src/Umbraco.Core/IO/IOHelper.cs +++ b/src/Umbraco.Core/IO/IOHelper.cs @@ -382,7 +382,7 @@ namespace Umbraco.Core.IO path = relativePath; } - return path.EnsurePathIsPrefixed(); + return path.EnsurePathIsApplicationRootPrefixed(); } /// @@ -390,8 +390,10 @@ namespace Umbraco.Core.IO /// /// /// - internal static string EnsurePathIsPrefixed(this string path) + internal static string EnsurePathIsApplicationRootPrefixed(this string path) { + if (path.StartsWith("~/")) + return path; if (path.StartsWith("/") == false && path.StartsWith("\\") == false) path = string.Format("/{0}", path); if (path.StartsWith("~") == false) diff --git a/src/Umbraco.Tests/IO/IOHelperTest.cs b/src/Umbraco.Tests/IO/IOHelperTest.cs index 559ba1a2f3..e42491454b 100644 --- a/src/Umbraco.Tests/IO/IOHelperTest.cs +++ b/src/Umbraco.Tests/IO/IOHelperTest.cs @@ -56,5 +56,14 @@ namespace Umbraco.Tests.IO Assert.AreEqual(IOHelper.MapPath(SystemDirectories.WebServices, true), IOHelper.MapPath(SystemDirectories.WebServices, false)); Assert.AreEqual(IOHelper.MapPath(SystemDirectories.Xslt, true), IOHelper.MapPath(SystemDirectories.Xslt, false)); } + + [Test] + public void EnsurePathIsApplicationRootPrefixed() + { + //Assert + Assert.AreEqual("~/Views/Template.cshtml", IOHelper.EnsurePathIsApplicationRootPrefixed("Views/Template.cshtml")); + Assert.AreEqual("~/Views/Template.cshtml", IOHelper.EnsurePathIsApplicationRootPrefixed("/Views/Template.cshtml")); + Assert.AreEqual("~/Views/Template.cshtml", IOHelper.EnsurePathIsApplicationRootPrefixed("~/Views/Template.cshtml")); + } } }