From 130b423c26d37a76e88e24f0efbbcb3f24b9727d Mon Sep 17 00:00:00 2001 From: Jaifroid Date: Sun, 19 Jan 2020 13:11:51 +0000 Subject: [PATCH] Correct location string Former-commit-id: 65a4c1e9a59bfab78ce0a374b24cd270a52f8a30 [formerly 6d6554b8576ad72b09c4649c1b7bcffe157034c3] Former-commit-id: d5ad4c5121bcb5e665d98817319bdfaa1c7f1c17 --- www/js/app.js | 4 ++-- www/js/lib/transformStyles.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/www/js/app.js b/www/js/app.js index 4e3d0b08..dbefdf8e 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -1130,7 +1130,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki var determinedWikiTheme = params.cssTheme == 'auto' ? cssUIThemeGetOrSet('auto', true) : params.cssTheme; var breakoutLink = doc.getElementById('breakoutLink'); // Construct an absolute reference becuase Service Worker needs this - var prefix = document.location.origin + document.location.pathname.replace(/\/[^/]*$/, ''); + var prefix = (window.location.protocol + '//' + window.location.host + window.location.pathname).replace(/\/[^/]*$/, ''); if (determinedWikiTheme != "light") { var link = doc.createElement("link"); link.setAttribute("rel", "stylesheet"); @@ -2838,7 +2838,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki //Preload stylesheets [kiwix-js #149] //Set up blobArray of promises - var prefix = document.location.origin + document.location.pathname.replace(/\/[^/]*$/, ''); + var prefix = (window.location.protocol + '//' + window.location.host + window.location.pathname).replace(/\/[^/]*$/, ''); var cssArray = htmlArticle.match(regexpSheetHref); var blobArray = []; var cssSource = params.cssSource; diff --git a/www/js/lib/transformStyles.js b/www/js/lib/transformStyles.js index 8dcb1f81..b4396e83 100644 --- a/www/js/lib/transformStyles.js +++ b/www/js/lib/transformStyles.js @@ -24,7 +24,7 @@ 'use strict'; define(['util', 'uiUtil'], function (util, uiUtil) { - var prefix = document.location.origin + document.location.pathname.replace(/\/[^/]*$/, '/'); + var prefix = (window.location.protocol + '//' + window.location.host + window.location.pathname).replace(/\/[^/]*$/, '/'); /* zl = zimLink; zim = zimType; cc = cssCache; cs = cssSource; i] */ function filterCSS(zl, zim, cc, cs, i) { var rtnFunction = "injectCSS";