Files
ohif-viewer/platform/core/src/utils/absoluteUrl.js
T

22 lines
544 B
JavaScript
Raw Normal View History

2019-08-13 15:36:46 -04:00
const absoluteUrl = path => {
let absolutePath = '/';
if (!path) {
return absolutePath;
}
2019-08-13 15:36:46 -04:00
// TODO: Find another way to get root url
const absoluteUrl = window.location.origin;
const absoluteUrlParts = absoluteUrl.split('/');
if (absoluteUrlParts.length > 4) {
const rootUrlPrefixIndex = absoluteUrl.indexOf(absoluteUrlParts[3]);
absolutePath += absoluteUrl.substring(rootUrlPrefixIndex) + path;
} else {
absolutePath += path;
}
return absolutePath.replace(/\/\/+/g, '/');
};
export default absoluteUrl;