Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in connection URL calcuation in ServerApp #761

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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