Remove ugly CharCollection hack

By adding a new configuration and mapping the old CharCollection to that, we can get around having to return null the first time, by obsoleting the old one and redirecting to the new GetCharReplacements method
This commit is contained in:
Mole
2021-12-22 11:29:04 +01:00
parent c6d28f01a8
commit 53e5a25df8
5 changed files with 81 additions and 74 deletions

View File

@@ -61,16 +61,7 @@ namespace Umbraco.Cms.Core.Strings
/// <returns>The short string helper.</returns>
public DefaultShortStringHelperConfig WithDefault(RequestHandlerSettings requestHandlerSettings)
{
// CharCollection could potentially be null if not invoked first by the framework, for instance in tests, so ensure that it's initialized.
IEnumerable<IChar> charCollection = requestHandlerSettings.CharCollection;
if (charCollection is null)
{
charCollection = requestHandlerSettings.CharCollection;
if (charCollection is null)
{
throw new ArgumentNullException(nameof(requestHandlerSettings.CharCollection));
}
}
IEnumerable<IChar> charCollection = requestHandlerSettings.GetCharReplacements();
UrlReplaceCharacters = charCollection
.Where(x => string.IsNullOrEmpty(x.Char) == false)