@@ -163,7 +163,12 @@ def get_uid_str(uid):
163163const { createRoot } = await importWithMap("react-dom/client", importMap);
164164
165165const e = React.createElement;
166+
167+ function isAbsoluteUrl(s) {
168+ return s.startsWith('http://') || s.startsWith('https://');
169+ }
166170const WORKSPACES_URL_KEYWORD = 'https://workspaces-pt';
171+ const OPTIONS_URL_KEYS = ['offsetsUrl', 'refSpecUrl'];
167172const 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
@@ -197,24 +202,25 @@ def get_uid_str(uid):
197202 datasets: config.datasets.map(d => ({
198203 ...d,
199204 files: d.files.map(f => {
200- // Update the main file URL
201- const updatedUrl = f.url.startsWith('http://') || f.url.startsWith('https://')
202- ? f.url
203- : `${origin}${baseUrl}${f.url}`;
204- // Update any urls within the options object
205- const updatedOptions = { ...f.options };
206- ['offsetsUrl', 'refSpecUrl'].forEach(key => {
207- if (updatedOptions.hasOwnProperty(key)) {
208- if (!updatedOptions[key].startsWith('http://') && !updatedOptions[key].startsWith('https://')) {
209- updatedOptions[key] = `${origin}${baseUrl}${updatedOptions[key]}`;
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) {
216+ if (!isAbsoluteUrl(optionValue)) {
217+ updatedOptions[key] = `${origin}${baseUrl}${optionValue}`;
218+ }
210219 }
211- }
212- });
213- return {
214- ...f,
215- url: updatedUrl,
216- options: updatedOptions,
217- };
220+ });
221+ updatedFileDef.options = updatedOptions;
222+ }
223+ return updatedFileDef;
218224 }),
219225 })),
220226 };
0 commit comments