From 30831733e1f115ca617db448041adc3895ed8e5d Mon Sep 17 00:00:00 2001 From: Radomir Stevanovic Date: Mon, 18 Sep 2023 04:59:55 -0700 Subject: [PATCH] Fix notebook URL opened in browser when redirect file not used With `notebook~=7.0` ServerApp is responsible for launching browser, not NotebookApp anymore. In `notebook~=6.0`, `launch_browser` will append notebook path for opening in browser even when `use_redirect_file` is set to `false` - unlike ServerApp, ever since 60c66b6a1. --- jupyter_server/serverapp.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jupyter_server/serverapp.py b/jupyter_server/serverapp.py index f9b9917772..612fa91444 100644 --- a/jupyter_server/serverapp.py +++ b/jupyter_server/serverapp.py @@ -2781,6 +2781,10 @@ def _prepare_browser_open(self): if self.identity_provider.token: uri = url_concat(uri, {"token": self.identity_provider.token}) + if self.file_to_run: + file_to_run_relpath = self._resolve_file_to_run_and_root_dir() + uri = url_escape(url_path_join(uri, *file_to_run_relpath.split(os.sep))) + if self.file_to_run: # noqa # Create a separate, temporary open-browser-file # pointing at a specific file.