Skip to content

Commit afe90fe

Browse files
committed
Included new URL types
1 parent 610af90 commit afe90fe

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/utils/storage.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,23 @@ async function savePreviews(url) {
6969

7070
// actually valid files don't need to have an extension in their URL
7171
// TODO: check mime-type instead
72-
if (!validExtensions.includes(ext)) {
72+
if (!validExtensions.includes(ext) && !fileName.endsWith('360_640')) {
7373
console.error("Unsupported Preview file extension", ext, "in URL", url);
7474
return false;
7575
}
7676

77+
// TODO: whitelist all static urls
78+
7779
if (filePath.includes('/preview-media/thumbnail_seq')) {
7880
// community-lens.storage.googleapis.com
7981
await downloadFile(previewUrl.toString(), filePath, fileName);
80-
} else if (filePath.startsWith('/previewmedia/')) {
82+
} else if (filePath.startsWith('/previewimage')) {
83+
// lens-storage.storage.googleapis.com
84+
const file = await downloadFile(previewUrl.toString(), filePath, fileName);
85+
} else if (filePath.startsWith('/previewvideo')) {
86+
// lens-storage.storage.googleapis.com
87+
const file = await downloadFile(previewUrl.toString(), filePath, fileName);
88+
} else if (filePath.startsWith('/previewmedia')) {
8189
// lens-preview-storage.storage.googleapis.com
8290
const file = await downloadFile(previewUrl.toString(), filePath, fileName);
8391
await convertWebpToPng(file);
@@ -118,6 +126,8 @@ async function savePNG(url) {
118126
let filePath = path.normalize(path.dirname(pngUrl.pathname));
119127
let fileName = path.basename(pngUrl.pathname);
120128

129+
// TODO: whitelist all static urls
130+
121131
if (filePath.endsWith("/png")) {
122132
// snapcodes.storage.googleapis.com
123133
// lens-storage.storage.googleapis.com

0 commit comments

Comments
 (0)