From 8745364e4ad209135959ed68dfff21ea2598fb8b Mon Sep 17 00:00:00 2001 From: Roy Orbitson Date: Wed, 21 May 2025 14:08:51 +0930 Subject: [PATCH 1/3] Improve local URL detection IPv4 loopback is 127/8, so treat entire range as local. --- jupyter_server/serverapp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jupyter_server/serverapp.py b/jupyter_server/serverapp.py index 1c70dd60a..6e1be93fc 100644 --- a/jupyter_server/serverapp.py +++ b/jupyter_server/serverapp.py @@ -2377,7 +2377,7 @@ def local_url(self) -> str: parts = self._get_urlparts(include_token=True) # Update with custom pieces. if not self.sock: - localhost = "[::1]" if ":" in self.ip else "127.0.0.1" + localhost = "[::1]" if ":" in self.ip else self.ip if self.ip.startswith("127.") else "127.0.0.1" parts = parts._replace(netloc=f"{localhost}:{self.port}") return parts.geturl() From be8045a0ffe03cc81722f4f8d48f5f3758767167 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 04:43:34 +0000 Subject: [PATCH 2/3] [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 | 8 +++++++- 2 files changed, 8 insertions(+), 2 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 6e1be93fc..91ffbcbae 100644 --- a/jupyter_server/serverapp.py +++ b/jupyter_server/serverapp.py @@ -2377,7 +2377,13 @@ def local_url(self) -> str: parts = self._get_urlparts(include_token=True) # Update with custom pieces. if not self.sock: - localhost = "[::1]" if ":" in self.ip else self.ip if self.ip.startswith("127.") else "127.0.0.1" + localhost = ( + "[::1]" + if ":" in self.ip + else self.ip + if self.ip.startswith("127.") + else "127.0.0.1" + ) parts = parts._replace(netloc=f"{localhost}:{self.port}") return parts.geturl() From df846232a1b7a728d6a7ec5158d50022d4ff381c Mon Sep 17 00:00:00 2001 From: Min RK Date: Wed, 21 May 2025 09:40:20 +0200 Subject: [PATCH 3/3] formatting in changelog Co-authored-by: Roy Orbitson --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd9910389..b1b78089e 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))