From 79aec1f7af6db21ee498721f425b122a53f14310 Mon Sep 17 00:00:00 2001 From: Shane McLaughlin Date: Thu, 28 Oct 2021 10:14:47 -0500 Subject: [PATCH] fix: keys split into 2 strings, which allows # in fullName (#474) Co-authored-by: Willie Ruemmele --- src/collections/componentSet.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/collections/componentSet.ts b/src/collections/componentSet.ts index 70c75cb9eb..6f9ee57daa 100644 --- a/src/collections/componentSet.ts +++ b/src/collections/componentSet.ts @@ -38,7 +38,7 @@ export type RetrieveSetOptions = Omit; /** * 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. @@ -310,7 +310,7 @@ export class ComponentSet extends LazyCollection { }; 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) { @@ -480,7 +480,7 @@ export class ComponentSet extends LazyCollection { public *[Symbol.iterator](): Iterator { 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), @@ -564,4 +564,9 @@ export class ComponentSet extends LazyCollection { 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)]; + } }