From 1158e45e9ddf507371786046e655f5b50d1895d5 Mon Sep 17 00:00:00 2001 From: Tony Spiro Date: Wed, 11 Sep 2024 10:35:24 -0700 Subject: [PATCH] fix: url issue --- package.json | 2 +- src/utils/addFullMedia.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index d53943f..9e572bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cosmicjs/sdk", - "version": "1.0.12", + "version": "1.0.13", "description": "The official client module for Cosmic. This module helps you easily add dynamic content to your website or application using the Cosmic headless CMS.", "keywords": [ "headlesscms", diff --git a/src/utils/addFullMedia.ts b/src/utils/addFullMedia.ts index 367f72f..6ea8d4e 100644 --- a/src/utils/addFullMedia.ts +++ b/src/utils/addFullMedia.ts @@ -16,8 +16,9 @@ const extractMediaFiles = (obj: any): string[] => { const mediaFiles: string[] = []; JSON.stringify(obj, (_, value) => { if (value && typeof value === 'object') { - if (value.url || value.imgix_url) { - mediaFiles.push(value.url.split('/').pop().split('?')[0]); + const url = value.imgix_url || value.url; + if (url) { + mediaFiles.push(url.split('/').pop().split('?')[0]); } } return value;