File tree Expand file tree Collapse file tree 1 file changed +18
-7
lines changed
Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Original file line number Diff line number Diff 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,
You can’t perform that action at this time.
0 commit comments