ximg: get fileid only after regex match
Signed-off-by: Varun Patil <radialapps@gmail.com>pull/672/head
parent
5e8967eb16
commit
32a4899194
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue