Browse Source

Fix #9378

Remove sort words before replacing dots with spaces
Bond_009 2 years ago
parent
commit
2e4905ff05
1 changed files with 15 additions and 15 deletions
  1. 15 15
      MediaBrowser.Controller/Entities/BaseItem.cs

+ 15 - 15
MediaBrowser.Controller/Entities/BaseItem.cs

@@ -893,16 +893,6 @@ namespace MediaBrowser.Controller.Entities
 
 
             var sortable = Name.Trim().ToLowerInvariant();
             var sortable = Name.Trim().ToLowerInvariant();
 
 
-            foreach (var removeChar in ConfigurationManager.Configuration.SortRemoveCharacters)
-            {
-                sortable = sortable.Replace(removeChar, string.Empty, StringComparison.Ordinal);
-            }
-
-            foreach (var replaceChar in ConfigurationManager.Configuration.SortReplaceCharacters)
-            {
-                sortable = sortable.Replace(replaceChar, " ", StringComparison.Ordinal);
-            }
-
             foreach (var search in ConfigurationManager.Configuration.SortRemoveWords)
             foreach (var search in ConfigurationManager.Configuration.SortRemoveWords)
             {
             {
                 // Remove from beginning if a space follows
                 // Remove from beginning if a space follows
@@ -921,12 +911,22 @@ namespace MediaBrowser.Controller.Entities
                 }
                 }
             }
             }
 
 
+            foreach (var removeChar in ConfigurationManager.Configuration.SortRemoveCharacters)
+            {
+                sortable = sortable.Replace(removeChar, string.Empty, StringComparison.Ordinal);
+            }
+
+            foreach (var replaceChar in ConfigurationManager.Configuration.SortReplaceCharacters)
+            {
+                sortable = sortable.Replace(replaceChar, " ", StringComparison.Ordinal);
+            }
+
             return ModifySortChunks(sortable);
             return ModifySortChunks(sortable);
         }
         }
 
 
-        internal static string ModifySortChunks(string name)
+        internal static string ModifySortChunks(ReadOnlySpan<char> name)
         {
         {
-            void AppendChunk(StringBuilder builder, bool isDigitChunk, ReadOnlySpan<char> chunk)
+            static void AppendChunk(StringBuilder builder, bool isDigitChunk, ReadOnlySpan<char> chunk)
             {
             {
                 if (isDigitChunk && chunk.Length < 10)
                 if (isDigitChunk && chunk.Length < 10)
                 {
                 {
@@ -936,7 +936,7 @@ namespace MediaBrowser.Controller.Entities
                 builder.Append(chunk);
                 builder.Append(chunk);
             }
             }
 
 
-            if (name.Length == 0)
+            if (name.IsEmpty)
             {
             {
                 return string.Empty;
                 return string.Empty;
             }
             }
@@ -950,13 +950,13 @@ namespace MediaBrowser.Controller.Entities
                 var isDigit = char.IsDigit(name[i]);
                 var isDigit = char.IsDigit(name[i]);
                 if (isDigit != isDigitChunk)
                 if (isDigit != isDigitChunk)
                 {
                 {
-                    AppendChunk(builder, isDigitChunk, name.AsSpan(chunkStart, i - chunkStart));
+                    AppendChunk(builder, isDigitChunk, name.Slice(chunkStart, i - chunkStart));
                     chunkStart = i;
                     chunkStart = i;
                     isDigitChunk = isDigit;
                     isDigitChunk = isDigit;
                 }
                 }
             }
             }
 
 
-            AppendChunk(builder, isDigitChunk, name.AsSpan(chunkStart));
+            AppendChunk(builder, isDigitChunk, name.Slice(chunkStart));
 
 
             // logger.LogDebug("ModifySortChunks Start: {0} End: {1}", name, builder.ToString());
             // logger.LogDebug("ModifySortChunks Start: {0} End: {1}", name, builder.ToString());
             return builder.ToString().RemoveDiacritics();
             return builder.ToString().RemoveDiacritics();