Преглед на файлове

fix: check if xhr.headers exists before reading

Gerald преди 3 години
родител
ревизия
0b514fcf65
променени са 1 файла, в които са добавени 5 реда и са изтрити 2 реда
  1. 5 2
      src/background/utils/storage-fetch.js

+ 5 - 2
src/background/utils/storage-fetch.js

@@ -55,9 +55,12 @@ export async function requestNewer(url, opts) {
     if (modOld || get) {
     if (modOld || get) {
       const req = await request(url, !get ? { ...opts, method: 'HEAD' } : opts);
       const req = await request(url, !get ? { ...opts, method: 'HEAD' } : opts);
       const { headers } = req;
       const { headers } = req;
-      const mod = headers.get('etag')
+      // headers does not exist when requesting a local file
+      const mod = headers && (
+        headers.get('etag')
         || +new Date(headers.get('last-modified'))
         || +new Date(headers.get('last-modified'))
-        || +new Date(headers.get('date'));
+        || +new Date(headers.get('date'))
+      );
       if (mod && mod === modOld) {
       if (mod && mod === modOld) {
         return;
         return;
       }
       }