From 84802970b4eed68100fd58a0490cb67aad7de664 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Wed, 5 Feb 2020 12:31:32 -0500
Subject: [PATCH] Fix URL root determination bug (VUFIND-1378).

---
 themes/bootstrap3/js/common.js | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/themes/bootstrap3/js/common.js b/themes/bootstrap3/js/common.js
index a0b93c1628f..4860cfd4266 100644
--- a/themes/bootstrap3/js/common.js
+++ b/themes/bootstrap3/js/common.js
@@ -163,13 +163,16 @@ function getUrlRoot(url) {
   var urlroot = null;
   var urlParts = url.split(/[?#]/);
   var urlWithoutFragment = urlParts[0];
+  var slashSlash = urlWithoutFragment.indexOf('//');
   if (VuFind.path === '' || VuFind.path === '/') {
     // special case -- VuFind installed at site root:
     var chunks = urlWithoutFragment.split('/');
-    urlroot = '/' + chunks[1] + '/' + chunks[2];
+    // We need to extract different offsets if this is a full vs. relative URL:
+    urlroot = slashSlash > -1
+      ? ('/' + chunks[3] + '/' + chunks[4])
+      : ('/' + chunks[1] + '/' + chunks[2]);
   } else {
     // standard case -- VuFind has its own path under site:
-    var slashSlash = urlWithoutFragment.indexOf('//');
     var pathInUrl = slashSlash > -1
       ? urlWithoutFragment.indexOf(VuFind.path, slashSlash + 2)
       : urlWithoutFragment.indexOf(VuFind.path);
-- 
GitLab