aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTyler Schicke <tyler_schicke@brown.edu>2019-07-08 19:04:05 -0400
committerTyler Schicke <tyler_schicke@brown.edu>2019-07-08 19:04:05 -0400
commitb10115fd6203bd5777c4fe2e0b2f24bb07793d3c (patch)
tree56969fb4fb13abb1a8bdf422679bdfba24ea141d
parentbe993c7bfd441a3a7d581371337c94fe692f0c65 (diff)
Added embedded images to GC
-rw-r--r--src/server/GarbageCollector.ts12
1 files changed, 12 insertions, 0 deletions
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;