2020-12-06 10:46:04 +01:00
|
|
|
// Copyright (c) Umbraco.
|
|
|
|
|
// See LICENSE for more details.
|
|
|
|
|
|
2021-12-22 11:29:04 +01:00
|
|
|
using System;
|
2020-12-06 10:46:04 +01:00
|
|
|
using System.Collections.Generic;
|
2021-07-05 14:27:49 +01:00
|
|
|
using System.ComponentModel;
|
2021-12-16 13:44:20 +01:00
|
|
|
using System.ComponentModel.DataAnnotations;
|
2021-02-18 11:06:02 +01:00
|
|
|
using Umbraco.Cms.Core.Configuration.UmbracoSettings;
|
|
|
|
|
using Umbraco.Extensions;
|
2020-08-23 23:36:48 +02:00
|
|
|
|
2021-02-18 11:06:02 +01:00
|
|
|
namespace Umbraco.Cms.Core.Configuration.Models
|
2020-08-23 23:36:48 +02:00
|
|
|
{
|
2020-12-06 10:46:04 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Typed configuration options for request handler settings.
|
|
|
|
|
/// </summary>
|
2021-06-24 08:47:37 +02:00
|
|
|
[UmbracoOptions(Constants.Configuration.ConfigRequestHandler)]
|
2020-08-23 23:36:48 +02:00
|
|
|
public class RequestHandlerSettings
|
|
|
|
|
{
|
2021-07-05 14:27:49 +01:00
|
|
|
internal const bool StaticAddTrailingSlash = true;
|
|
|
|
|
internal const string StaticConvertUrlsToAscii = "try";
|
2021-10-15 23:22:01 +01:00
|
|
|
internal const bool StaticEnableDefaultCharReplacements = true;
|
2021-07-05 14:27:49 +01:00
|
|
|
|
2022-01-26 10:20:12 +01:00
|
|
|
internal static readonly Umbraco.Cms.Core.Configuration.Models.CharItem[] DefaultCharCollection =
|
2020-08-23 23:36:48 +02:00
|
|
|
{
|
2021-10-15 23:22:01 +01:00
|
|
|
new () { Char = " ", Replacement = "-" },
|
|
|
|
|
new () { Char = "\"", Replacement = string.Empty },
|
|
|
|
|
new () { Char = "'", Replacement = string.Empty },
|
|
|
|
|
new () { Char = "%", Replacement = string.Empty },
|
|
|
|
|
new () { Char = ".", Replacement = string.Empty },
|
|
|
|
|
new () { Char = ";", Replacement = string.Empty },
|
|
|
|
|
new () { Char = "/", Replacement = string.Empty },
|
|
|
|
|
new () { Char = "\\", Replacement = string.Empty },
|
|
|
|
|
new () { Char = ":", Replacement = string.Empty },
|
|
|
|
|
new () { Char = "#", Replacement = string.Empty },
|
|
|
|
|
new () { Char = "+", Replacement = "plus" },
|
|
|
|
|
new () { Char = "*", Replacement = "star" },
|
|
|
|
|
new () { Char = "&", Replacement = string.Empty },
|
|
|
|
|
new () { Char = "?", Replacement = string.Empty },
|
|
|
|
|
new () { Char = "æ", Replacement = "ae" },
|
|
|
|
|
new () { Char = "ä", Replacement = "ae" },
|
|
|
|
|
new () { Char = "ø", Replacement = "oe" },
|
|
|
|
|
new () { Char = "ö", Replacement = "oe" },
|
|
|
|
|
new () { Char = "å", Replacement = "aa" },
|
|
|
|
|
new () { Char = "ü", Replacement = "ue" },
|
|
|
|
|
new () { Char = "ß", Replacement = "ss" },
|
|
|
|
|
new () { Char = "|", Replacement = "-" },
|
|
|
|
|
new () { Char = "<", Replacement = string.Empty },
|
|
|
|
|
new () { Char = ">", Replacement = string.Empty }
|
2020-08-23 23:36:48 +02:00
|
|
|
};
|
|
|
|
|
|
2020-12-06 10:46:04 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets a value indicating whether to add a trailing slash to URLs.
|
|
|
|
|
/// </summary>
|
2021-07-05 14:27:49 +01:00
|
|
|
[DefaultValue(StaticAddTrailingSlash)]
|
|
|
|
|
public bool AddTrailingSlash { get; set; } = StaticAddTrailingSlash;
|
2020-08-23 23:36:48 +02:00
|
|
|
|
2020-12-06 10:46:04 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets a value indicating whether to convert URLs to ASCII (valid values: "true", "try" or "false").
|
|
|
|
|
/// </summary>
|
2021-07-05 14:27:49 +01:00
|
|
|
[DefaultValue(StaticConvertUrlsToAscii)]
|
|
|
|
|
public string ConvertUrlsToAscii { get; set; } = StaticConvertUrlsToAscii;
|
2020-08-23 23:36:48 +02:00
|
|
|
|
2020-12-06 10:46:04 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a value indicating whether URLs should be converted to ASCII.
|
|
|
|
|
/// </summary>
|
2020-08-25 10:45:54 +02:00
|
|
|
public bool ShouldConvertUrlsToAscii => ConvertUrlsToAscii.InvariantEquals("true");
|
|
|
|
|
|
2020-12-06 10:46:04 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Gets a value indicating whether URLs should be tried to be converted to ASCII.
|
|
|
|
|
/// </summary>
|
2020-08-25 10:45:54 +02:00
|
|
|
public bool ShouldTryConvertUrlsToAscii => ConvertUrlsToAscii.InvariantEquals("try");
|
2020-08-23 23:36:48 +02:00
|
|
|
|
2021-10-15 23:22:01 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Disable all default character replacements
|
|
|
|
|
/// </summary>
|
|
|
|
|
[DefaultValue(StaticEnableDefaultCharReplacements)]
|
|
|
|
|
public bool EnableDefaultCharReplacements { get; set; } = StaticEnableDefaultCharReplacements;
|
2020-08-23 23:36:48 +02:00
|
|
|
|
2020-12-06 10:46:04 +01:00
|
|
|
/// <summary>
|
2021-10-15 23:22:01 +01:00
|
|
|
/// Add additional character replacements, or override defaults
|
2020-12-06 10:46:04 +01:00
|
|
|
/// </summary>
|
2021-12-22 11:29:04 +01:00
|
|
|
[Obsolete("Use the GetCharReplacements extension method in the Umbraco.Extensions namespace instead. Scheduled for removal in V11")]
|
2020-08-25 12:30:43 +02:00
|
|
|
public IEnumerable<IChar> CharCollection { get; set; } = DefaultCharCollection;
|
2020-08-23 23:36:48 +02:00
|
|
|
|
2020-12-06 10:46:04 +01:00
|
|
|
/// <summary>
|
2021-12-22 11:29:04 +01:00
|
|
|
/// Add additional character replacements, or override defaults
|
2020-12-06 10:46:04 +01:00
|
|
|
/// </summary>
|
2022-02-16 16:03:53 +01:00
|
|
|
public IEnumerable<Umbraco.Cms.Core.Configuration.Models.CharItem>? UserDefinedCharCollection { get; set; }
|
2020-08-23 23:36:48 +02:00
|
|
|
}
|
|
|
|
|
}
|