From b10115fd6203bd5777c4fe2e0b2f24bb07793d3c Mon Sep 17 00:00:00 2001 From: Tyler Schicke Date: Mon, 8 Jul 2019 19:04:05 -0400 Subject: Added embedded images to GC --- src/server/GarbageCollector.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/server/GarbageCollector.ts b/src/server/GarbageCollector.ts index fa182af40..3c32a94c2 100644 --- a/src/server/GarbageCollector.ts +++ b/src/server/GarbageCollector.ts @@ -32,6 +32,18 @@ function addDoc(doc: any, ids: string[], files: { [name: string]: string[] }) { ids.push(split[split.length - 1]); } } + const re2 = /"src"\s*:\s*"(.*?)"/g; + while ((match = re2.exec(field.Data)) !== null) { + const urlString = match[1]; + const pathname = new URL(urlString).pathname; + const ext = path.extname(pathname); + const fileName = path.basename(pathname, ext); + let exts = files[fileName]; + if (!exts) { + files[fileName] = exts = []; + } + exts.push(ext); + } } else if (["audio", "image", "video", "pdf", "web"].includes(field.__type)) { const url = new URL(field.url); const pathname = url.pathname; -- cgit v1.2.3-70-g09d2