From 0b2f93ed930209d7ba1ecad7eb6386a39b0d329c Mon Sep 17 00:00:00 2001 From: Jaifroid Date: Sun, 14 Feb 2021 16:42:43 +0000 Subject: [PATCH] Calculate appRootDir for app:// links Former-commit-id: 6ec21d22a9e04de963708b16ef845ef27401ed69 [formerly 76238b17c91ceb885d0368bfc3cdb24ff709067b [formerly cf0ea6b5c397c6ef96ae9204b0a6b99add06f426]] Former-commit-id: 65e3134615bbec6302da0b1bba4b8dba7a1bed1b Former-commit-id: 18bab5412d1b36615904399def77f7d32b638ae1 --- www/js/app.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/www/js/app.js b/www/js/app.js index 8be5e0cf..5dfdab01 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -3286,7 +3286,10 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett htmlArticle = htmlArticle.replace(/href\s*=\s*"\s*geo:([\d.-]+),([\d.-]+)/ig, 'href="bingmaps:?collection=point.$1_$2_' + encodeURIComponent(dirEntry.getTitleOrUrl())); // Process any app:// links (these are always from the app payload) to match the current protocol - htmlArticle = htmlArticle.replace(/(['"])app:\/\//g, '$1' + window.location.protocol + '//'); + htmlArticle = htmlArticle.replace(/(['"])app:\/\//g, function (p0, p1) { + var appRootDir = window.location.href.replace(/\/www\/index\.html.*$/i, ''); + return p1 + appRootDir; + }); //Setup endnote backlinks if the ZIM doesn't have any htmlArticle = htmlArticle.replace(/]+id=["']cite[-_]note[-_]([^"']+)[^>]+>(?![^/]+?[↑^])/ig, function (match, id) {