Skip to content

Commit e61fce9

Browse files
tkakarkeller-mark
andauthored
Updated url for options object (#424)
* Updated url for options object * Add if statements and isAbsoluteUrl function * Update if statement --------- Co-authored-by: Mark Keller <[email protected]>
1 parent 1ecdb39 commit e61fce9

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Python API and Jupyter widget facilitating interactive visualization of spatial
1414

1515
To install with pip:
1616

17-
$ pip install vitessce[all]
17+
$ pip install 'vitessce[all]'
1818

1919
## Getting started
2020

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.5.7"
7+
version = "3.5.8"
88
authors = [
99
{ name="Mark Keller", email="[email protected]" },
1010
]

src/vitessce/widget.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,12 @@ def get_uid_str(uid):
163163
const { createRoot } = await importWithMap("react-dom/client", importMap);
164164
165165
const e = React.createElement;
166+
167+
function isAbsoluteUrl(s) {
168+
return s.startsWith('http://') || s.startsWith('https://');
169+
}
166170
const WORKSPACES_URL_KEYWORD = 'https://workspaces-pt';
171+
const OPTIONS_URL_KEYS = ['offsetsUrl', 'refSpecUrl'];
167172
const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
168173
// The jupyter server may be running through a proxy,
169174
// which means that the client needs to prepend the part of the URL before /proxy/8000 such as
@@ -196,13 +201,25 @@ def get_uid_str(uid):
196201
...config,
197202
datasets: config.datasets.map(d => ({
198203
...d,
199-
files: d.files.map(f => ({
200-
...f,
201-
url: (!(f.url.startsWith('http://') || f.url.startsWith('https://'))
202-
? `${origin}${baseUrl}${f.url}`
203-
: f.url
204-
),
205-
})),
204+
files: d.files.map(f => {
205+
const updatedFileDef = { ...f };
206+
if (!isAbsoluteUrl(f.url)) {
207+
// Update the main file URL if necessary.
208+
updatedFileDef.url = `${origin}${baseUrl}${f.url}`;
209+
}
210+
if (f.options) {
211+
// Update any urls within the options object
212+
const updatedOptions = { ...f.options };
213+
OPTIONS_URL_KEYS.forEach(key => {
214+
const optionValue = updatedOptions[key];
215+
if (optionValue && !isAbsoluteUrl(optionValue)) {
216+
updatedOptions[key] = `${origin}${baseUrl}${optionValue}`;
217+
}
218+
});
219+
updatedFileDef.options = updatedOptions;
220+
}
221+
return updatedFileDef;
222+
}),
206223
})),
207224
};
208225
}

0 commit comments

Comments
 (0)