Skip to content

Commit

Permalink
fix: keys split into 2 strings, which allows # in fullName (#474)
Browse files Browse the repository at this point in the history
Co-authored-by: Willie Ruemmele <[email protected]>
  • Loading branch information
mshanemc and WillieRuemmele authored Oct 28, 2021
1 parent 72c51fa commit 79aec1f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/collections/componentSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export type RetrieveSetOptions = Omit<MetadataApiRetrieveOptions, 'components'>;

/**
* A collection containing no duplicate metadata members (`fullName` and `type` pairs). `ComponentSets`
* are a convinient way of constructing a unique collection of components to perform operations such as
* are a convenient way of constructing a unique collection of components to perform operations such as
* deploying and retrieving.
*
* Multiple {@link SourceComponent}s can be present in the set and correspond to the same member.
Expand Down Expand Up @@ -310,7 +310,7 @@ export class ComponentSet extends LazyCollection<MetadataComponent> {
};

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

if (type.folderContentType) {
Expand Down Expand Up @@ -480,7 +480,7 @@ export class ComponentSet extends LazyCollection<MetadataComponent> {
public *[Symbol.iterator](): Iterator<MetadataComponent> {
for (const [key, sourceComponents] of this.components.entries()) {
if (sourceComponents.size === 0) {
const [typeName, fullName] = key.split(ComponentSet.KEY_DELIMITER);
const [typeName, fullName] = this.splitOnFirstDelimiter(key);
yield {
fullName,
type: this.registry.getTypeByName(typeName),
Expand Down Expand Up @@ -564,4 +564,9 @@ export class ComponentSet extends LazyCollection<MetadataComponent> {
const typeName = typeof component.type === 'string' ? component.type.toLowerCase().trim() : component.type.id;
return `${typeName}${ComponentSet.KEY_DELIMITER}${component.fullName}`;
}

private splitOnFirstDelimiter(input: string): [string, string] {
const indexOfSplitChar = input.indexOf(ComponentSet.KEY_DELIMITER);
return [input.substring(0, indexOfSplitChar), input.substring(indexOfSplitChar + 1)];
}
}

0 comments on commit 79aec1f

Please sign in to comment.