From b75f082a1151f793b00e2fb4e1c5ce786e7bbc64 Mon Sep 17 00:00:00 2001 From: Roy Orbitson Date: Wed, 21 May 2025 15:47:35 +0930 Subject: [PATCH 1/2] Send user to custom URL Send user to configured custom URL upon launch, instead of one constructed from bound IP address. --- jupyter_server/serverapp.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/jupyter_server/serverapp.py b/jupyter_server/serverapp.py index 1c70dd60a..d9d27e91b 100644 --- a/jupyter_server/serverapp.py +++ b/jupyter_server/serverapp.py @@ -2359,9 +2359,9 @@ def _get_urlparts( ) return urlparts - @property - def public_url(self) -> str: - parts = self._get_urlparts(include_token=True) + def _customize_url( + self, parts: type[urllib.parse.ParseResult] + ) -> urllib.parse.ParseResult: # Update with custom pieces. if self.custom_display_url: # Parse custom display_url @@ -2370,6 +2370,12 @@ def public_url(self) -> str: custom_updates = {key: item for key, item in custom.items() if item} # Update public URL parts with custom pieces. parts = parts._replace(**custom_updates) + return parts + + @property + def public_url(self) -> str: + parts = self._get_urlparts(include_token=True) + parts = self._customize_url(parts) return parts.geturl() @property @@ -2394,6 +2400,7 @@ def display_url(self) -> str: @property def connection_url(self) -> str: urlparts = self._get_urlparts(path=self.base_url) + urlparts = self._customize_url(urlparts) return urlparts.geturl() def init_signal(self) -> None: From 5db3b81ad9665ecd147b9c467ce8ebd2cab81058 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 21 May 2025 06:27:40 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- CHANGELOG.md | 2 +- jupyter_server/serverapp.py | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 995919121..cd9910389 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ All notable changes to this project will be documented in this file. ### Enhancements made -- If ServerApp.ip is ipv6 use [::1] as local_url [#1495](https://github.com/jupyter-server/jupyter_server/pull/1495) ([@manics](https://github.com/manics)) +- If ServerApp.ip is ipv6 use \[::1\] as local_url [#1495](https://github.com/jupyter-server/jupyter_server/pull/1495) ([@manics](https://github.com/manics)) - Don't hide .so,.dylib files by default [#1457](https://github.com/jupyter-server/jupyter_server/pull/1457) ([@nokados](https://github.com/nokados)) - Add async start hook to ExtensionApp API [#1417](https://github.com/jupyter-server/jupyter_server/pull/1417) ([@Zsailer](https://github.com/Zsailer)) diff --git a/jupyter_server/serverapp.py b/jupyter_server/serverapp.py index d9d27e91b..5c84f014c 100644 --- a/jupyter_server/serverapp.py +++ b/jupyter_server/serverapp.py @@ -2359,9 +2359,7 @@ def _get_urlparts( ) return urlparts - def _customize_url( - self, parts: type[urllib.parse.ParseResult] - ) -> urllib.parse.ParseResult: + def _customize_url(self, parts: type[urllib.parse.ParseResult]) -> urllib.parse.ParseResult: # Update with custom pieces. if self.custom_display_url: # Parse custom display_url