Skip to content

Commit 4a4ef0e

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 2a895ac commit 4a4ef0e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

sphinx_book_theme/launch.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,10 @@ def add_hub_urls(
103103
context["binder_url"] = url
104104

105105
if jupyterhub_url:
106+
repo_esc = repo_url.replace(':', '%3A')
106107
url = (
107108
f"{jupyterhub_url}/hub/user-redirect/git-pull?"
108-
f"repo={repo_url}&urlpath={ui_pre}/{repo}/{path_rel_repo}&branch={branch}"
109+
f"repo={repo_esc}&urlpath={ui_pre}/{repo}/{path_rel_repo}&branch={branch}"
109110
)
110111
context["jupyterhub_url"] = url
111112

0 commit comments

Comments
 (0)