|
@@ -86,20 +86,22 @@ from metadata.conf import has_optimizer, OPTIMIZER
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- 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.
|
|
|
|
|
- index += window.location.host.length;
|
|
|
|
|
- arguments[1] = arguments[1].substring(0, index) + window.HUE_BASE_URL + arguments[1].substring(index);
|
|
|
|
|
- } else {
|
|
|
|
|
- arguments[1] = window.HUE_BASE_URL + arguments[1];
|
|
|
|
|
|
|
+ // 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
|
|
|
|
|
+ index += window.location.host.length;
|
|
|
|
|
+ arguments[1] = arguments[1].substring(0, index) + window.HUE_BASE_URL + arguments[1].substring(index);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ arguments[1] = window.HUE_BASE_URL + arguments[1];
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- return xhrOpen.apply(this, arguments);
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ return xhrOpen.apply(this, arguments);
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
var xhrSend = XMLHttpRequest.prototype.send;
|
|
var xhrSend = XMLHttpRequest.prototype.send;
|
|
|
XMLHttpRequest.prototype.send = function (data) {
|
|
XMLHttpRequest.prototype.send = function (data) {
|
|
|
// Add CSRF Token to all XHR Requests
|
|
// Add CSRF Token to all XHR Requests
|