diff --git a/src/Umbraco.Core/Configuration/GlobalSettings.cs b/src/Umbraco.Core/Configuration/GlobalSettings.cs index 8e17689ea1..8199ebfda5 100644 --- a/src/Umbraco.Core/Configuration/GlobalSettings.cs +++ b/src/Umbraco.Core/Configuration/GlobalSettings.cs @@ -223,7 +223,7 @@ namespace Umbraco.Core.Configuration /// The fullpath to root. public static string FullpathToRoot { - get { return HttpRuntime.AppDomainAppPath; } + get { return IOHelper.GetRootDirectorySafe(); } } /// diff --git a/src/Umbraco.Core/Models/ContentExtensions.cs b/src/Umbraco.Core/Models/ContentExtensions.cs index 10151455e7..ef8bd636df 100644 --- a/src/Umbraco.Core/Models/ContentExtensions.cs +++ b/src/Umbraco.Core/Models/ContentExtensions.cs @@ -393,7 +393,7 @@ namespace Umbraco.Core.Models //nodeName should match Casing.SafeAliasWithForcingCheck(content.ContentType.Alias); //var nodeName = content.ContentType.Alias.ToUmbracoAlias(StringAliasCaseType.CamelCase, true); var nodeName = content.ContentType.Alias; - var niceUrl = content.Name.Replace(" ", "-").ToLower(); + var niceUrl = content.Name.FormatUrl().ToLower() ; var xml = new XElement(nodeName, new XAttribute("id", content.Id), diff --git a/src/Umbraco.Core/StringExtensions.cs b/src/Umbraco.Core/StringExtensions.cs index 514df2088d..cc2818b03c 100644 --- a/src/Umbraco.Core/StringExtensions.cs +++ b/src/Umbraco.Core/StringExtensions.cs @@ -9,6 +9,8 @@ using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using System.Web; +using System.Xml; +using Umbraco.Core.Configuration; namespace Umbraco.Core { @@ -739,5 +741,24 @@ namespace Umbraco.Core ? input : alternative; } + + public static string FormatUrl(this string url) + { + string _newUrl = url; + XmlNode replaceChars = UmbracoSettings.UrlReplaceCharacters; + foreach (XmlNode n in replaceChars.SelectNodes("char")) + { + if (n.Attributes.GetNamedItem("org") != null && n.Attributes.GetNamedItem("org").Value != "") + _newUrl = _newUrl.Replace(n.Attributes.GetNamedItem("org").Value, Umbraco.Core.XmlHelper.GetNodeValue(n)); + } + + // check for double dashes + if (UmbracoSettings.RemoveDoubleDashesFromUrlReplacing) + { + _newUrl = Regex.Replace(_newUrl, @"[-]{2,}", "-"); + } + + return _newUrl; + } } }