ximg: get fileid only after regex match

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

View File

@ -214,9 +214,8 @@ async function fetchImage(url: string): Promise<Blob> {
const cache = await imageCache?.match(url);
if (cache) return await cache.blob();
// Get file id from URL
// Parse URL
const urlObj = new URL(url, self.location.origin);
const fileid = Number(urlObj.pathname.split('/').pop());
// Just fetch if not a preview
const regex = /^.*\/apps\/memories\/api\/image\/preview\/.*/;
@ -227,6 +226,9 @@ async function fetchImage(url: string): Promise<Blob> {
return await res.blob();
}
// Get file id from URL
const fileid = Number(urlObj.pathname.split('/').pop());
return await new Promise((resolve, reject) => {
if (pendingUrls.has(url)) {
// Already in queue, just add callback