Refactor absoluteUrl to allow multiple domains directed to the same server work
This commit is contained in:
parent
25690ef888
commit
8957b4ed8b
@ -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, '/');
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user