瀏覽代碼

Account for tree URLs when there is a workspace collision. Fixes https://github.com/jupyterlab/jupyterlab/issues/5214

Afshin Darian 6 年之前
父節點
當前提交
959d6c601a
共有 1 個文件被更改,包括 6 次插入2 次删除
  1. 6 2
      packages/apputils-extension/src/index.ts

+ 6 - 2
packages/apputils-extension/src/index.ts

@@ -642,7 +642,6 @@ namespace Private {
       focusNodeSelector: 'input',
       buttons: [Dialog.okButton({ label: 'Switch Workspace' })]
     });
-
     const result = await dialog.launch();
 
     dialog.dispose();
@@ -651,8 +650,13 @@ namespace Private {
     }
 
     // Navigate to a new workspace URL and abandon this session altogether.
+    const page = PageConfig.getOption('pageUrl');
     const workspaces = PageConfig.getOption('workspacesUrl');
-    const url = URLExt.join(workspaces, result.value);
+    const match = router.current.path.match(Patterns.workspace);
+    const workspace = (match && decodeURIComponent(match[1])) || '';
+    const prefix = (workspace ? workspaces : page).length + workspace.length;
+    const rest = router.current.request.substring(prefix);
+    const url = URLExt.join(workspaces, result.value, rest);
 
     router.navigate(url, { hard: true, silent: true });