Fix viewer link host resolution
This commit is contained in:
@@ -240,9 +240,22 @@ function markNode(id, state, strong, meta) {
|
||||
node.querySelector("em").textContent = meta;
|
||||
}
|
||||
|
||||
function viewerBaseUrl() {
|
||||
try {
|
||||
const url = new URL(app.viewerUrl || `${location.protocol}//${location.hostname}:8107`, location.href);
|
||||
if (["127.0.0.1", "localhost", "0.0.0.0"].includes(url.hostname) && !["127.0.0.1", "localhost"].includes(location.hostname)) {
|
||||
url.hostname = location.hostname;
|
||||
}
|
||||
url.protocol = location.protocol;
|
||||
return url.toString().replace(/\/$/, "");
|
||||
} catch (_) {
|
||||
return `${location.protocol}//${location.hostname}:8107`;
|
||||
}
|
||||
}
|
||||
|
||||
function dicomViewerUrl(row = app.active) {
|
||||
if (!row?.pacs_ct_number) return "";
|
||||
return `${app.viewerUrl.replace(/\/$/, "")}/?ct_number=${encodeURIComponent(row.pacs_ct_number)}`;
|
||||
return `${viewerBaseUrl()}/?ct_number=${encodeURIComponent(row.pacs_ct_number)}`;
|
||||
}
|
||||
|
||||
function updateOpenDicomButton() {
|
||||
@@ -539,7 +552,7 @@ function openDicomViewer() {
|
||||
}
|
||||
|
||||
function openViewerHome() {
|
||||
window.open(app.viewerUrl.replace(/\/$/, ""), "_blank", "noopener");
|
||||
window.open(viewerBaseUrl(), "_blank", "noopener");
|
||||
}
|
||||
|
||||
function wire() {
|
||||
|
||||
Reference in New Issue
Block a user