Skip to content
Snippets Groups Projects
Commit 74a9468b authored by juanf's avatar juanf
Browse files

SSDM-4841 : bugfix, finding correct base url even with scripts loaded from a different domain

SVN: 37853
parent 09656e61
No related branches found
No related tags found
No related merge requests found
var require = (function() {
var getBaseUrl = function() {
var path = window.location.pathname;
var index = path.substr(1).indexOf("/") + 1;
var baseUrl = path.substring(0, index) + "/resources";
// To find where the V3 API has been loaded from we scan the script tags until finding this file
// This way is possible to load the V3 API from a separate domain
var scripts = document.getElementsByTagName("script");
var baseUrl = null;
for(var sIdx = 0; sIdx < scripts.length; sIdx++) {
var src = scripts[sIdx].src;
var substringEnd = -1;
if((substringEnd = src.indexOf("/api/v3/config.js")) > -1) {
baseUrl = src.substring(0, substringEnd+"/api/v3".length);
}
}
return baseUrl;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment