From f11bf21fdca2edeefc7c14892f020c10c5f29e1d Mon Sep 17 00:00:00 2001 From: Jaifroid Date: Sun, 17 Dec 2023 14:58:56 +0000 Subject: [PATCH] Fix undefined this --- www/js/lib/zimArchive.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/js/lib/zimArchive.js b/www/js/lib/zimArchive.js index 5c90ed7e..874719a9 100644 --- a/www/js/lib/zimArchive.js +++ b/www/js/lib/zimArchive.js @@ -796,7 +796,7 @@ ZIMArchive.prototype.getUtf8FromData = function (data) { * @return {Promise} A Promise that resolves to a Directory Entry, or null if not found. */ ZIMArchive.prototype.getDirEntryByPath = function (path, zimitResolving, originalPath, followRedirects) { - var that = this; + var that = this || appstate.selectedArchive; if (that.zimType === 'zimit' && (!appstate.isReplayWorkerAvailable || followRedirects)) { if (originalPath) appstate.originalPath = originalPath; path = path.replace(/\?kiwix-display/, ''); @@ -812,7 +812,7 @@ ZIMArchive.prototype.getDirEntryByPath = function (path, zimitResolving, origina } } } - return util.binarySearch(0, this.file.entryCount, function (i) { + return util.binarySearch(0, that.file.entryCount, function (i) { return that.file.dirEntryByUrlIndex(i).then(function (dirEntry) { var url = dirEntry.namespace + '/' + dirEntry.url; if (path < url) {