Add ASCII file name conversion (#17580)

(cherry picked from commit 4590739fa5)
(cherry picked from commit 3d1505d4c6)
This commit is contained in:
Kenn Jacobsen
2024-11-26 11:26:44 +01:00
committed by kjac
parent 4f3f2efbdc
commit 444c87469c
2 changed files with 29 additions and 3 deletions

View File

@@ -74,12 +74,21 @@ public class DefaultShortStringHelperConfig
{
urlSegmentConvertTo = CleanStringType.Ascii;
}
if (requestHandlerSettings.ShouldTryConvertUrlsToAscii)
else if (requestHandlerSettings.ShouldTryConvertUrlsToAscii)
{
urlSegmentConvertTo = CleanStringType.TryAscii;
}
CleanStringType fileNameSegmentConvertTo = CleanStringType.Utf8;
if (requestHandlerSettings.ShouldConvertFileNamesToAscii)
{
fileNameSegmentConvertTo = CleanStringType.Ascii;
}
else if (requestHandlerSettings.ShouldTryConvertFileNamesToAscii)
{
fileNameSegmentConvertTo = CleanStringType.TryAscii;
}
return WithConfig(CleanStringType.UrlSegment, new Config
{
PreFilter = ApplyUrlReplaceCharacters,
@@ -92,7 +101,7 @@ public class DefaultShortStringHelperConfig
{
PreFilter = ApplyUrlReplaceCharacters,
IsTerm = (c, leading) => char.IsLetterOrDigit(c) || c == '_', // letter, digit or underscore
StringType = CleanStringType.Utf8 | CleanStringType.LowerCase,
StringType = fileNameSegmentConvertTo | CleanStringType.LowerCase,
BreakTermsOnUpper = false,
Separator = '-',
}).WithConfig(CleanStringType.Alias, new Config