Skip to content

Commit 4087b98

Browse files
Regression in connection URL calcuation in ServerApp (#761)
Co-authored-by: FriendlyBot <[email protected]>
1 parent e0c126f commit 4087b98

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

jupyter_server/serverapp.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1976,8 +1976,10 @@ def _get_urlparts(self, path=None, include_token=False):
19761976
scheme = "http+unix"
19771977
netloc = urlencode_unix_socket_path(self.sock)
19781978
else:
1979+
if not self.ip:
1980+
ip = "localhost"
19791981
# Handle nonexplicit hostname.
1980-
if self.ip in ("", "0.0.0.0", "::"):
1982+
elif self.ip in ("0.0.0.0", "::"):
19811983
ip = "%s" % socket.gethostname()
19821984
else:
19831985
ip = "[{}]".format(self.ip) if ":" in self.ip else self.ip

tests/test_serverapp.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,12 @@ def test_resolve_file_to_run_and_root_dir(prefix_path, root_dir, file_to_run, ex
229229
"http+unix://%2Ftmp%2Fjp-test.sock/test/?token=<generated>",
230230
"http+unix://%2Ftmp%2Fjp-test.sock/",
231231
),
232+
(
233+
{"ip": ""},
234+
"http://localhost:8888/?token=<generated>",
235+
"http://127.0.0.1:8888/?token=<generated>",
236+
"http://localhost:8888/",
237+
),
232238
],
233239
)
234240
def test_urls(config, public_url, local_url, connection_url):

0 commit comments

Comments
 (0)