jellyfish-web/src/components/require/requiretext.js

43 lines
1 KiB
JavaScript
Raw Normal View History

define(function () {
'use strict';
// hack to work around the server's auto-redirection feature
2020-10-07 21:12:14 +09:00
const addRedirectPrevention = window.dashboardVersion != null && window.Dashboard && !window.AppInfo.isNativeApp;
2018-10-23 01:05:09 +03:00
return {
load: function (url, req, load, config) {
if (url.indexOf('://') === -1) {
url = config.baseUrl + url;
}
if (config.urlArgs) {
url += config.urlArgs(url, url);
}
if (addRedirectPrevention) {
if (url.indexOf('?') === -1) {
url += '?';
} else {
url += '&';
}
url += 'r=0';
}
2020-10-07 21:12:14 +09:00
const xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.onload = function (e) {
load(this.response);
};
xhr.send();
2018-10-23 01:05:09 +03:00
},
normalize: function (name, normalize) {
return normalize(name);
2018-10-23 01:05:09 +03:00
}
};
});