Merge pull request #617 from Unrud/base_prefix

Fix absolute paths in web interface when SCRIPT_NAME is used
This commit is contained in:
Unrud 2017-06-01 12:37:07 +02:00 committed by GitHub
commit 8528a4c3f8

View File

@ -17,13 +17,19 @@
*/ */
/** /**
* Server address (must not end with /) * Server address
* @const * @const
* @type {string} * @type {string}
*/ */
var SERVER = (location.protocol + '//' + location.hostname + var SERVER = (location.protocol + '//' + location.hostname +
(location.port ? ':' + location.port : '') + (location.port ? ':' + location.port : ''));
location.pathname.replace(new RegExp("/+[^/]+/*(/index\.html?)?$"), ""));
/**
* Path of the root collection on the server (must end with /)
* @const
* @type {string}
*/
var ROOT_PATH = location.pathname.replace(new RegExp("/+[^/]+/*(/index\.html?)?$"), "") + '/';
/** /**
* time between updates of collections. * time between updates of collections.
@ -121,7 +127,7 @@ function Collection(href, type, displayname, description, color) {
*/ */
function get_principal(user, password, callback) { function get_principal(user, password, callback) {
var request = new XMLHttpRequest(); var request = new XMLHttpRequest();
request.open("PROPFIND", SERVER, true, user, password); request.open("PROPFIND", SERVER + ROOT_PATH, true, user, password);
request.onreadystatechange = function() { request.onreadystatechange = function() {
if (request.readyState !== 4) { if (request.readyState !== 4) {
return; return;