@@ -38,7 +38,7 @@ export type RetrieveSetOptions = Omit<MetadataApiRetrieveOptions, 'components'>;
38
38
39
39
/**
40
40
* A collection containing no duplicate metadata members (`fullName` and `type` pairs). `ComponentSets`
41
- * are a convinient way of constructing a unique collection of components to perform operations such as
41
+ * are a convenient way of constructing a unique collection of components to perform operations such as
42
42
* deploying and retrieving.
43
43
*
44
44
* Multiple {@link SourceComponent}s can be present in the set and correspond to the same member.
@@ -310,7 +310,7 @@ export class ComponentSet extends LazyCollection<MetadataComponent> {
310
310
} ;
311
311
312
312
for ( const key of components . keys ( ) ) {
313
- const [ typeId , fullName ] = key . split ( ComponentSet . KEY_DELIMITER ) ;
313
+ const [ typeId , fullName ] = this . splitOnFirstDelimiter ( key ) ;
314
314
let type = this . registry . getTypeByName ( typeId ) ;
315
315
316
316
if ( type . folderContentType ) {
@@ -480,7 +480,7 @@ export class ComponentSet extends LazyCollection<MetadataComponent> {
480
480
public * [ Symbol . iterator ] ( ) : Iterator < MetadataComponent > {
481
481
for ( const [ key , sourceComponents ] of this . components . entries ( ) ) {
482
482
if ( sourceComponents . size === 0 ) {
483
- const [ typeName , fullName ] = key . split ( ComponentSet . KEY_DELIMITER ) ;
483
+ const [ typeName , fullName ] = this . splitOnFirstDelimiter ( key ) ;
484
484
yield {
485
485
fullName,
486
486
type : this . registry . getTypeByName ( typeName ) ,
@@ -564,4 +564,9 @@ export class ComponentSet extends LazyCollection<MetadataComponent> {
564
564
const typeName = typeof component . type === 'string' ? component . type . toLowerCase ( ) . trim ( ) : component . type . id ;
565
565
return `${ typeName } ${ ComponentSet . KEY_DELIMITER } ${ component . fullName } ` ;
566
566
}
567
+
568
+ private splitOnFirstDelimiter ( input : string ) : [ string , string ] {
569
+ const indexOfSplitChar = input . indexOf ( ComponentSet . KEY_DELIMITER ) ;
570
+ return [ input . substring ( 0 , indexOfSplitChar ) , input . substring ( indexOfSplitChar + 1 ) ] ;
571
+ }
567
572
}
0 commit comments