Skip to content

Send user to custom URL #1526

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
11 changes: 8 additions & 3 deletions jupyter_server/serverapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2359,9 +2359,7 @@ 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
Expand All @@ -2370,6 +2368,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
Expand All @@ -2394,6 +2398,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:
Expand Down
Loading