ximg: improve preview check regex

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/672/head
Varun Patil 2023-05-29 11:57:34 -07:00
parent 32a4899194
commit 5ed210710f
1 changed files with 2 additions and 4 deletions

View File

@ -214,11 +214,8 @@ async function fetchImage(url: string): Promise<Blob> {
const cache = await imageCache?.match(url);
if (cache) return await cache.blob();
// Parse URL
const urlObj = new URL(url, self.location.origin);
// Just fetch if not a preview
const regex = /^.*\/apps\/memories\/api\/image\/preview\/.*/;
const regex = /\/memories\/api\/image\/preview\/\d+(\?.*)?$/;
if (!regex.test(url)) {
const res = await fetchOneImage(url);
@ -227,6 +224,7 @@ async function fetchImage(url: string): Promise<Blob> {
}
// Get file id from URL
const urlObj = new URL(url, self.location.origin);
const fileid = Number(urlObj.pathname.split('/').pop());
return await new Promise((resolve, reject) => {