diff --git a/Packages/ohif-core/both/utils/absoluteUrl.js b/Packages/ohif-core/both/utils/absoluteUrl.js index f695e2269..4b1dbdf7e 100644 --- a/Packages/ohif-core/both/utils/absoluteUrl.js +++ b/Packages/ohif-core/both/utils/absoluteUrl.js @@ -1,11 +1,19 @@ import { OHIF } from 'meteor/ohif:core'; -// Return an absolute URL with the given path by supporting the leading "/" +// Return an absolute URL with the page domain using sub path of ROOT_URL +// to let multiple domains directed to the same server work OHIF.utils.absoluteUrl = function(path) { - if (path) { - // Remove the leading "/" - path = path.replace(/^\//, ''); + let absolutePath = '/'; + + const absoluteUrl = Meteor.absoluteUrl(); + const absoluteUrlParts = absoluteUrl.split('/'); + + if (absoluteUrlParts.length > 4) { + const rootUrlPrefixIndex = absoluteUrl.indexOf(absoluteUrlParts[3]); + absolutePath += absoluteUrl.substring(rootUrlPrefixIndex) + path; + } else { + absolutePath += path; } - return Meteor.absoluteUrl(path); + return absolutePath.replace(/\/\/+/g, '/'); }; \ No newline at end of file