@factorypure/client-helpers 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +12 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -183,8 +183,18 @@ const handleIndexSearch = (dataToSearch, filters, variant, filterOptions) => {
183
183
  };
184
184
  const filterLinkedElsewhereResults = (results, variantId) => {
185
185
  const filtered = results.filter((result) => {
186
- const productLinkedElsewhere = result.linked_variant_ids?.length > 0 &&
187
- !result.linked_variant_ids.includes(variantId);
186
+ const linkedVariantIds = result.linked_variant_ids || [];
187
+ let parsedLinkedVariantIds = linkedVariantIds;
188
+ if (!Array.isArray(linkedVariantIds)) {
189
+ try {
190
+ parsedLinkedVariantIds = JSON.parse(linkedVariantIds);
191
+ }
192
+ catch {
193
+ parsedLinkedVariantIds = [];
194
+ }
195
+ }
196
+ const productLinkedElsewhere = linkedVariantIds.length > 0 &&
197
+ !linkedVariantIds.includes(variantId);
188
198
  if (productLinkedElsewhere) {
189
199
  return false;
190
200
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@factorypure/client-helpers",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",