From c41f3002f3118b1f195c5c822fe0f400091d115b Mon Sep 17 00:00:00 2001 From: Adrien de Peretti Date: Thu, 21 Dec 2023 10:28:13 +0100 Subject: [PATCH] fix(utils): More resilient object from string path (#5929) **What** More resilient util in case an undefined, nu,, '' value is passed as part of the relations --- .changeset/mighty-jokes-prove.md | 5 +++++ packages/utils/src/common/object-from-string-path.ts | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 .changeset/mighty-jokes-prove.md diff --git a/.changeset/mighty-jokes-prove.md b/.changeset/mighty-jokes-prove.md new file mode 100644 index 0000000000..646c31ad9a --- /dev/null +++ b/.changeset/mighty-jokes-prove.md @@ -0,0 +1,5 @@ +--- +"@medusajs/utils": patch +--- + +Fix/utils object from string path diff --git a/packages/utils/src/common/object-from-string-path.ts b/packages/utils/src/common/object-from-string-path.ts index 77177cffdf..26de1fbf22 100644 --- a/packages/utils/src/common/object-from-string-path.ts +++ b/packages/utils/src/common/object-from-string-path.ts @@ -49,6 +49,9 @@ export function objectFromStringPath( const output: Record = {} for (const relation of collection) { + if (!relation) { + continue + } if (relation.indexOf(".") > -1) { const nestedRelations = relation.split(".")