From 1e047ae985cf0e8a014bbf8528506bc46f1dacb4 Mon Sep 17 00:00:00 2001 From: Jaifroid Date: Sun, 28 May 2023 21:45:28 +0100 Subject: [PATCH] Add secondary URL corrector to increase fidelity of Zimit rendering --- www/js/lib/zimArchive.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/www/js/lib/zimArchive.js b/www/js/lib/zimArchive.js index 41d17ea4..a09abce8 100644 --- a/www/js/lib/zimArchive.js +++ b/www/js/lib/zimArchive.js @@ -724,9 +724,16 @@ ZIMArchive.prototype.getDirEntryByPath = function(path, zimitResolving, original if (originalPath) appstate.originalPath = originalPath; path = path.replace(/\?kiwix-display/, ''); // Correct obvious errors - // if (that._file.zimType === 'zimit' && !zimitResolving) { - // path = that._file.minorVersion === 1 ? path.replace(/^.*(C\/A\/.*)$/, '$1') : path.replace(/^.*(A\/.*)$/, '$1'); - // }; + if (!originalPath) { + var revisedPath = path.replace(/.*?((?:C\/A|A)\/(?!.*(?:C\/A|A)).+)$/, '$1'); + if (revisedPath !== path) { + console.warn('*** Revised path from ' + path + '\nto: ' + revisedPath + ' ***'); + if (appstate.selectedArchive._file.zimType === 'zimit') { + console.debug('*** DEV: Consider correcting this error in tranformZimit.js ***'); + } + path = revisedPath; + } + } return util.binarySearch(0, this._file.entryCount, function(i) { return that._file.dirEntryByUrlIndex(i).then(function(dirEntry) { var url = dirEntry.namespace + "/" + dirEntry.url;