@@ -24,7 +24,7 @@ public class ApiItemProvider
2424 IApiStaticDataProvider apiStaticDataProvider
2525) : IApiItemProvider
2626{
27- public Dictionary < string , List < ( Regex Regex , ItemApiInformation Item ) > > NameDictionary { get ; private set ; } = [ ] ;
27+ public List < ( Regex Regex , ItemApiInformation Item ) > NamePatterns { get ; private set ; } = [ ] ;
2828
2929 public List < ( Regex Regex , ItemApiInformation Item ) > TypePatterns { get ; private set ; } = [ ] ;
3030
@@ -45,8 +45,7 @@ public async Task Initialize()
4545 if ( result == null ) throw new SidekickException ( "Could not fetch items from the trade API." ) ;
4646
4747 InitializeItems ( game , result ) ;
48- UniqueItems = NameDictionary . SelectMany ( x => x . Value )
49- . Select ( x => x . Item )
48+ UniqueItems = NamePatterns . Select ( x => x . Item )
5049 . Where ( x => x . IsUnique )
5150 . OrderByDescending ( x => x . Name ? . Length )
5251 . ToList ( ) ;
@@ -57,7 +56,7 @@ public async Task Initialize()
5756
5857 private void InitializeItems ( GameType game , FetchResult < ApiCategory > result )
5958 {
60- NameDictionary . Clear ( ) ;
59+ NamePatterns . Clear ( ) ;
6160 TypePatterns . Clear ( ) ;
6261 TextPatterns . Clear ( ) ;
6362
@@ -100,13 +99,8 @@ private void FillCategoryItems(List<ApiCategory> categories, string categoryId,
10099
101100 if ( ! string . IsNullOrEmpty ( information . Name ) )
102101 {
103- if ( ! NameDictionary . TryGetValue ( information . Name , out var namePatterns ) )
104- {
105- namePatterns = new List < ( Regex Regex , ItemApiInformation Item ) > ( ) ;
106- NameDictionary . Add ( information . Name , namePatterns ) ;
107- }
108-
109- namePatterns . Add ( ( new Regex ( Regex . Escape ( information . Name ) ) , information ) ) ;
102+ var regex = $ "^{ Regex . Escape ( information . Name ) } |{ Regex . Escape ( information . Name ) } $";
103+ NamePatterns . Add ( ( new Regex ( regex ) , information ) ) ;
110104 }
111105
112106 if ( ! string . IsNullOrEmpty ( information . Type ) && ! information . IsUnique )
0 commit comments