Skip to content

Commit

Permalink
Regression in connection URL calcuation in ServerApp (#761)
Browse files Browse the repository at this point in the history
Co-authored-by: FriendlyBot <meeseeksmachine@gmail.com>
  • Loading branch information
jhamet93 and meeseeksmachine committed Mar 27, 2022
1 parent e0c126f commit 4087b98
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion jupyter_server/serverapp.py
Expand Up @@ -1976,8 +1976,10 @@ def _get_urlparts(self, path=None, include_token=False):
scheme = "http+unix"
netloc = urlencode_unix_socket_path(self.sock)
else:
if not self.ip:
ip = "localhost"
# Handle nonexplicit hostname.
if self.ip in ("", "0.0.0.0", "::"):
elif self.ip in ("0.0.0.0", "::"):
ip = "%s" % socket.gethostname()
else:
ip = "[{}]".format(self.ip) if ":" in self.ip else self.ip
Expand Down
6 changes: 6 additions & 0 deletions tests/test_serverapp.py
Expand Up @@ -229,6 +229,12 @@ def test_resolve_file_to_run_and_root_dir(prefix_path, root_dir, file_to_run, ex
"http+unix://%2Ftmp%2Fjp-test.sock/test/?token=<generated>",
"http+unix://%2Ftmp%2Fjp-test.sock/",
),
(
{"ip": ""},
"http://localhost:8888/?token=<generated>",
"http://127.0.0.1:8888/?token=<generated>",
"http://localhost:8888/",
),
],
)
def test_urls(config, public_url, local_url, connection_url):
Expand Down

0 comments on commit 4087b98

Please sign in to comment.