File tree Expand file tree Collapse file tree 2 files changed +15
-13
lines changed Expand file tree Collapse file tree 2 files changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -220,14 +220,15 @@ export function mapClientID2NameSorted(
220
220
return [ ] ;
221
221
}
222
222
223
- // If any element in the array contains keyword markers, return the array as-is
224
- if ( Array . isArray ( enabledClients ) && enabledClients . some ( ( client ) => hasKeywordMarkers ( client ) ) ) {
225
- return enabledClients ;
226
- }
223
+ // Process each element: preserve keyword markers, convert client IDs to names
224
+ const processedClients = enabledClients . map ( ( client ) => {
225
+ if ( hasKeywordMarkers ( client ) ) {
226
+ return client ;
227
+ }
228
+ return convertClientIdToName ( client , knownClients ) ;
229
+ } ) ;
227
230
228
- return [
229
- ...( enabledClients || [ ] ) . map ( ( clientId ) => convertClientIdToName ( clientId , knownClients ) ) ,
230
- ] . sort ( ( a , b ) => a . toLowerCase ( ) . localeCompare ( b . toLowerCase ( ) ) ) ;
231
+ return processedClients . sort ( ( a , b ) => a . toLowerCase ( ) . localeCompare ( b . toLowerCase ( ) ) ) ;
231
232
}
232
233
233
234
export function nomalizedYAMLPath ( filePath : string ) : string [ ] {
Original file line number Diff line number Diff line change @@ -121,15 +121,16 @@ describe('#mapClientID2NameSorted', () => {
121
121
expect ( result ) . to . deep . equal ( [ ] ) ;
122
122
} ) ;
123
123
124
- it ( 'should handle null/undefined enabled clients' , ( ) => {
125
- const result = mapClientID2NameSorted ( null , mockClients ) ;
126
- expect ( result ) . to . deep . equal ( [ ] ) ;
124
+ it ( 'should handle empty string enabled clients' , ( ) => {
125
+ const result = mapClientID2NameSorted ( '' , mockClients ) ;
126
+ expect ( result ) . to . deep . equal ( '' ) ;
127
127
} ) ;
128
128
129
129
it ( 'should preserve keyword markers in arrays' , ( ) => {
130
- const enabledClientsWithKeywords = [ '@@ CLIENT_KEYWORD@@ ' , 'client-a-id' ] ;
130
+ const enabledClientsWithKeywords = [ '## CLIENT_KEYWORD## ' , 'client-a-id' ] ;
131
131
const result = mapClientID2NameSorted ( enabledClientsWithKeywords , mockClients ) ;
132
- // When an array contains keyword markers, the entire array should be returned as-is
133
- expect ( result ) . to . deep . equal ( enabledClientsWithKeywords ) ;
132
+
133
+ const expectedClientsWithKeywords = [ '##CLIENT_KEYWORD##' , 'Client A' ] ;
134
+ expect ( result ) . to . deep . equal ( expectedClientsWithKeywords ) ;
134
135
} ) ;
135
136
} ) ;
You can’t perform that action at this time.
0 commit comments