Skip to content

Commit 79aec1f

Browse files
fix: keys split into 2 strings, which allows # in fullName (#474)
Co-authored-by: Willie Ruemmele <[email protected]>
1 parent 72c51fa commit 79aec1f

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/collections/componentSet.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export type RetrieveSetOptions = Omit<MetadataApiRetrieveOptions, 'components'>;
3838

3939
/**
4040
* 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
4242
* deploying and retrieving.
4343
*
4444
* 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> {
310310
};
311311

312312
for (const key of components.keys()) {
313-
const [typeId, fullName] = key.split(ComponentSet.KEY_DELIMITER);
313+
const [typeId, fullName] = this.splitOnFirstDelimiter(key);
314314
let type = this.registry.getTypeByName(typeId);
315315

316316
if (type.folderContentType) {
@@ -480,7 +480,7 @@ export class ComponentSet extends LazyCollection<MetadataComponent> {
480480
public *[Symbol.iterator](): Iterator<MetadataComponent> {
481481
for (const [key, sourceComponents] of this.components.entries()) {
482482
if (sourceComponents.size === 0) {
483-
const [typeName, fullName] = key.split(ComponentSet.KEY_DELIMITER);
483+
const [typeName, fullName] = this.splitOnFirstDelimiter(key);
484484
yield {
485485
fullName,
486486
type: this.registry.getTypeByName(typeName),
@@ -564,4 +564,9 @@ export class ComponentSet extends LazyCollection<MetadataComponent> {
564564
const typeName = typeof component.type === 'string' ? component.type.toLowerCase().trim() : component.type.id;
565565
return `${typeName}${ComponentSet.KEY_DELIMITER}${component.fullName}`;
566566
}
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+
}
567572
}

0 commit comments

Comments
 (0)