From f078a2ae82ce5d15e98d7ddff8273a2f2f1186a9 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 17 Mar 2015 14:47:24 +0000 Subject: [PATCH] Fix for protocol detection and problems converting absolute to relative paths, from Thomas Kurschel. --- phpgwapi/js/jsapi/egw_files.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/phpgwapi/js/jsapi/egw_files.js b/phpgwapi/js/jsapi/egw_files.js index 9b573cb420..ddc0a177c8 100644 --- a/phpgwapi/js/jsapi/egw_files.js +++ b/phpgwapi/js/jsapi/egw_files.js @@ -90,9 +90,14 @@ egw.extend('files', egw.MODULE_WND_LOCAL, function(_app, _wnd) var file = _urls[i]; // check if egw_url is only path and urls contains full url incl. protocol // --> prefix it with our protocol and host, as eg. splitting by just '/' will fail! - var need_full_url = egw_url[0] == '/' && file.substr(4) == 'http' ? window.location.protocol+'://'+window.location.host : ''; - var parts = file.split(need_full_url+egw_url,2); - if (parts.length == 2) _urls[i] = parts[1]; + var need_full_url = egw_url[0] == '/' && file.substr(0,4) == 'http' ? window.location.protocol+'//'+window.location.host : ''; + var parts = file.split(need_full_url+egw_url); + if (parts.length > 1) + { + // discard protocol and host + parts.shift(); + _urls[i] = parts.join(need_full_url+egw_url); + } } return _urls; }