Skip to content

Commit 41b30a3

Browse files
Miriadbuilder
andcommitted
fix: filter derived Cloudinary URLs from migration
Skip coverImage.derived[], videoCloudinary.derived[], and other sub-fields of cloudinary.asset objects that contain transformed URL variants. These don't need separate uploads since the entire cloudinary.asset object gets replaced. Reduces unique URLs from 6,985 to 282 base assets. Co-authored-by: builder <builder@miriad.systems>
1 parent 02c21e7 commit 41b30a3

File tree

2 files changed

+355
-0
lines changed

2 files changed

+355
-0
lines changed

scripts/migration/migrate.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,15 @@ function findCloudinaryRefs(obj, currentPath = '') {
316316

317317
if (typeof obj === 'string') {
318318
if (containsCloudinaryRef(obj)) {
319+
// Skip URLs that are inside cloudinary.asset sub-fields (derived, url, secure_url)
320+
// These will be replaced when the parent cloudinary.asset object is swapped out
321+
const skipPatterns = ['.derived[', '.secure_url', '.url'];
322+
const isSubField = skipPatterns.some((p) => currentPath.includes(p)) &&
323+
(currentPath.includes('coverImage') || currentPath.includes('videoCloudinary') || currentPath.includes('ogImage'));
324+
if (isSubField) {
325+
return results;
326+
}
327+
319328
const urls = extractCloudinaryUrls(obj);
320329
const isFullUrl = obj.trim().startsWith('http') && !obj.includes(' ') && urls.length === 1;
321330

scripts/migration/package-lock.json

Lines changed: 346 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)