Skip to content

Commit 6cbdedf

Browse files
authored
Fixed path in the images array (#453)
* Fixed path in the images array * U[dated version
1 parent ac8ad74 commit 6cbdedf

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "vitessce"
7-
version = "3.6.3"
7+
version = "3.6.4"
88
authors = [
99
{ name="Mark Keller", email="[email protected]" },
1010
]

src/vitessce/widget.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def get_uid_str(uid):
163163
const e = React.createElement;
164164
165165
function isAbsoluteUrl(s) {
166-
return s.startsWith('http://') || s.startsWith('https://');
166+
return s?.startsWith('http://') || s?.startsWith('https://');
167167
}
168168
const WORKSPACES_URL_KEYWORD = 'https://workspaces-pt';
169169
const OPTIONS_URL_KEYS = ['offsetsUrl', 'refSpecUrl'];
@@ -201,7 +201,7 @@ def get_uid_str(uid):
201201
...d,
202202
files: d.files.map(f => {
203203
const updatedFileDef = { ...f };
204-
if (!isAbsoluteUrl(f.url)) {
204+
if (f.url && !isAbsoluteUrl(f.url) ) {
205205
// Update the main file URL if necessary.
206206
updatedFileDef.url = `${origin}${baseUrl}${f.url}`;
207207
}
@@ -214,6 +214,28 @@ def get_uid_str(uid):
214214
updatedOptions[key] = `${origin}${baseUrl}${optionValue}`;
215215
}
216216
});
217+
218+
// Update image URLs if they exist
219+
if ('images' in f.options && Array.isArray(f.options.images)) {
220+
const updatedImages = f.options.images.map(image => {
221+
const updatedImage = { ...image };
222+
223+
if (image.url && !isAbsoluteUrl(image.url)) {
224+
updatedImage.url = `${origin}${baseUrl}${image.url}`;
225+
}
226+
227+
const metadata = { ...image.metadata };
228+
if (metadata?.omeTiffOffsetsUrl && !isAbsoluteUrl(metadata.omeTiffOffsetsUrl)) {
229+
metadata.omeTiffOffsetsUrl = `${origin}${baseUrl}${metadata.omeTiffOffsetsUrl}`;
230+
}
231+
232+
updatedImage.metadata = metadata;
233+
234+
return updatedImage;
235+
});
236+
237+
updatedOptions.images = updatedImages;
238+
}
217239
updatedFileDef.options = updatedOptions;
218240
}
219241
return updatedFileDef;

0 commit comments

Comments
 (0)