[knox] Enable XHR URL rewrite only if Knox is there
@@ -86,12 +86,13 @@ from metadata.conf import has_optimizer, OPTIMIZER
}
}
-
+ // Enable XHR URL rewrite if Knox is there
+ if (window.HUE_BASE_URL && window.HUE_BASE_URL.length) {
var xhrOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function () {
if (arguments[1].indexOf(window.HUE_BASE_URL) < 0) {
var index = arguments[1].indexOf(window.location.host);
- if (index >= 0 && window.HUE_BASE_URL.length) { //Host is present in the url when using an html form.
+ if (index >= 0 && window.HUE_BASE_URL.length) { // Host is present in the URL when using an HTML form
index += window.location.host.length;
arguments[1] = arguments[1].substring(0, index) + window.HUE_BASE_URL + arguments[1].substring(index);
} else {
@@ -100,6 +101,7 @@ from metadata.conf import has_optimizer, OPTIMIZER
}
return xhrOpen.apply(this, arguments);
};
+ }
var xhrSend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function (data) {
// Add CSRF Token to all XHR Requests
