Skip to content

Commit e6896bb

Browse files
committed
Escape colon in JupyterHub link to repo
I've run into a problem using The Littlest JupyterHub with current `sphinx-book-theme`. At the moment the generated URLs for JupyterHub are of form: ``` <hub-url>/hub/user-redirect/git-pull?repo=https://<repo>&urlpath=tree/<nb_fname> ``` These work fine on a modern Kubernetes JupyterHub, I guess because of a recent version of JupyterHub responding to the query. But, on current The Littlest JupyterHub, still on JupyterHub 1.5.0, this causes Nbgitpuller to stall if the user is not already logged in, with log messages of form: ``` Disallowing redirect outside JupyterHub: '/hub/user-redirect/git-pull?repo=https://github.com/<repo>&urlpath=tree/<nb_fname>'. ``` Once logged in, retrying the same link works correctly. This can be fixed by escaping the `:` in the Nbgitpuller URL with a `%3A`, in this PR.
1 parent c4755c7 commit e6896bb

File tree

1 file changed

+2
-1
lines changed
  • src/sphinx_book_theme/header_buttons

1 file changed

+2
-1
lines changed

src/sphinx_book_theme/header_buttons/launch.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,10 @@ def add_launch_buttons(
118118
)
119119

120120
if jupyterhub_url:
121+
repo_esc = repo_url.replace(':', '%3A')
121122
url = (
122123
f"{jupyterhub_url}/hub/user-redirect/git-pull?"
123-
f"repo={repo_url}&urlpath={ui_pre}/{repo}/{path_rel_repo}&branch={branch}"
124+
f"repo={repo_esc}&urlpath={ui_pre}/{repo}/{path_rel_repo}&branch={branch}"
124125
)
125126
launch_buttons_list.append(
126127
{

0 commit comments

Comments
 (0)