Enhance DICOM image URL handling to support standard web images without forcing wadouri scheme
This commit is contained in:
@@ -599,10 +599,20 @@ async function setUpDicom3d(element) {
|
|||||||
|
|
||||||
|
|
||||||
// Prepare imageIds: ensure remote URLs are usable by dicom-image-loader (wadouri:)
|
// Prepare imageIds: ensure remote URLs are usable by dicom-image-loader (wadouri:)
|
||||||
|
// but avoid forcing wadouri: for standard web images (png/jpg/etc) because
|
||||||
|
// the dicom parser will fail when given non-DICOM files. For such images
|
||||||
|
// return the raw URL so the appropriate web-image loader can handle them.
|
||||||
const imageIds = images.map((url) => {
|
const imageIds = images.map((url) => {
|
||||||
url = url.trim();
|
url = url.trim();
|
||||||
// if it's already a scheme we pass through; otherwise treat as wadouri
|
// if it's already a scheme we pass through
|
||||||
if (/^(wadouri:|base64:|data:)/i.test(url)) return url;
|
if (/^(wadouri:|base64:|data:|http:|https:)/i.test(url)) return url;
|
||||||
|
|
||||||
|
// If the URL looks like a regular web image, don't treat it as DICOM
|
||||||
|
if (url.match(/\.(png|jpe?g|gif|bmp|webp)$/i)) {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
// default: treat as wadouri (likely a DICOM file)
|
||||||
return `wadouri:${url}`;
|
return `wadouri:${url}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user