Skip to content

Commit 2e0051c

Browse files
committed
Updated prependbaseUrl
1 parent 560c63d commit 2e0051c

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/vitessce/widget.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,26 @@ def get_uid_str(uid):
172172
return config;
173173
}
174174
const { origin } = new URL(window.location.href);
175+
const pathSegments = window.location.pathname.split('/');
175176
let baseUrl;
176-
const jupyterLabConfigEl = document.getElementById('jupyter-config-data');
177-
178-
if (jupyterLabConfigEl) {
179-
// This is jupyter lab
180-
baseUrl = JSON.parse(jupyterLabConfigEl.textContent || '').baseUrl;
177+
const passthroughIndex = pathSegments.indexOf('passthrough');
178+
if (passthroughIndex !== -1) {
179+
baseUrl = pathSegments.slice(0, passthroughIndex + 3).join('/');
181180
} else {
182-
// This is jupyter notebook
183-
baseUrl = document.getElementsByTagName('body')[0].getAttribute('data-base-url');
181+
const jupyterLabConfigEl = document.getElementById('jupyter-config-data');
182+
183+
if (jupyterLabConfigEl) {
184+
// This is jupyter lab
185+
baseUrl = JSON.parse(jupyterLabConfigEl.textContent || '').baseUrl;
186+
} else {
187+
// This is jupyter notebook
188+
baseUrl = document.getElementsByTagName('body')[0].getAttribute('data-base-url');
189+
}
190+
}
191+
192+
// Ensure baseUrl starts with a slash
193+
if (!baseUrl.startsWith('/')) {
194+
baseUrl = '/' + baseUrl;
184195
}
185196
return {
186197
...config,

0 commit comments

Comments
 (0)