Files
Umbraco-CMS/src/Umbraco.Core/Configuration/Models/RequestHandlerSettings.cs

72 lines
2.9 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Core.Configuration.Models
{
public class RequestHandlerSettings
{
2020-08-24 16:06:09 +02:00
internal static readonly CharItem[] DefaultCharCollection =
{
new CharItem { Char = " ", Replacement = "-" },
new CharItem { Char = "\"", Replacement = "" },
new CharItem { Char = "'", Replacement = "" },
new CharItem { Char = "%", Replacement = "" },
new CharItem { Char = ".", Replacement = "" },
new CharItem { Char = ";", Replacement = "" },
new CharItem { Char = "/", Replacement = "" },
new CharItem { Char = "\\", Replacement = "" },
new CharItem { Char = ":", Replacement = "" },
new CharItem { Char = "#", Replacement = "" },
new CharItem { Char = "+", Replacement = "plus" },
new CharItem { Char = "*", Replacement = "star" },
new CharItem { Char = "&", Replacement = "" },
new CharItem { Char = "?", Replacement = "" },
new CharItem { Char = "æ", Replacement = "ae" },
new CharItem { Char = "ä", Replacement = "ae" },
new CharItem { Char = "ø", Replacement = "oe" },
new CharItem { Char = "ö", Replacement = "oe" },
new CharItem { Char = "å", Replacement = "aa" },
new CharItem { Char = "ü", Replacement = "ue" },
new CharItem { Char = "ß", Replacement = "ss" },
new CharItem { Char = "|", Replacement = "-" },
new CharItem { Char = "<", Replacement = "" },
new CharItem { Char = ">", Replacement = "" }
};
public bool AddTrailingSlash { get; set; } = true;
public string ConvertUrlsToAscii { get; set; } = "try";
public bool ShouldConvertUrlsToAscii => ConvertUrlsToAscii.InvariantEquals("true");
public bool ShouldTryConvertUrlsToAscii => ConvertUrlsToAscii.InvariantEquals("try");
//We need to special handle ":", as this character is special in keys
2020-08-24 16:06:09 +02:00
// TODO: implement from configuration
2020-08-24 16:06:09 +02:00
//var collection = _configuration.GetSection(Prefix + "CharCollection").GetChildren()
// .Select(x => new CharItem()
// {
// Char = x.GetValue<string>("Char"),
// Replacement = x.GetValue<string>("Replacement"),
// }).ToArray();
2020-08-24 16:06:09 +02:00
//if (collection.Any() || _configuration.GetSection("Prefix").GetChildren().Any(x =>
// x.Key.Equals("CharCollection", StringComparison.OrdinalIgnoreCase)))
//{
// return collection;
//}
2020-08-24 16:06:09 +02:00
// return DefaultCharCollection;
public IEnumerable<IChar> CharCollection { get; set; }
public class CharItem : IChar
{
public string Char { get; set; }
2020-08-24 16:06:09 +02:00
public string Replacement { get; set; }
}
}
}