Skip to content

Commit 5721a63

Browse files
FIX: Escape colon in JupyterHub link to repo (#556)
1 parent c4755c7 commit 5721a63

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

src/sphinx_book_theme/header_buttons/launch.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from pathlib import Path
22
from typing import Any, Dict, Optional
3+
from urllib.parse import urlencode
34

45
from docutils.nodes import document
56
from sphinx.application import Sphinx
@@ -118,10 +119,13 @@ def add_launch_buttons(
118119
)
119120

120121
if jupyterhub_url:
121-
url = (
122-
f"{jupyterhub_url}/hub/user-redirect/git-pull?"
123-
f"repo={repo_url}&urlpath={ui_pre}/{repo}/{path_rel_repo}&branch={branch}"
122+
url_params = urlencode(
123+
dict(
124+
repo=repo_url, urlpath=f"{ui_pre}/{repo}/{path_rel_repo}", branch=branch
125+
),
126+
safe="/",
124127
)
128+
url = f"{jupyterhub_url}/hub/user-redirect/git-pull?{url_params}"
125129
launch_buttons_list.append(
126130
{
127131
"type": "link",

tests/test_build/build__header-article.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
</a>
2828
</li>
2929
<li>
30-
<a class="headerbtn" data-placement="left" data-toggle="tooltip" href="https://datahub.berkeley.edu/hub/user-redirect/git-pull?repo=https://github.com/executablebooks/sphinx-book-theme&amp;urlpath=lab/tree/sphinx-book-theme/TESTPATH/section1/ntbk.ipynb&amp;branch=master" title="Launch on JupyterHub">
30+
<a class="headerbtn" data-placement="left" data-toggle="tooltip" href="https://datahub.berkeley.edu/hub/user-redirect/git-pull?repo=https%3A//github.com/executablebooks/sphinx-book-theme&amp;urlpath=lab/tree/sphinx-book-theme/TESTPATH/section1/ntbk.ipynb&amp;branch=master" title="Launch on JupyterHub">
3131
<span class="headerbtn__icon-container">
3232
<img src="../_static/images/logo_jupyterhub.svg"/>
3333
</span>

tests/test_build/test_header_launchbtns.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</a>
1717
</li>
1818
<li>
19-
<a class="headerbtn" data-placement="left" data-toggle="tooltip" href="https://datahub.berkeley.edu/hub/user-redirect/git-pull?repo=https://github.com/executablebooks/sphinx-book-theme&amp;urlpath=lab/tree/sphinx-book-theme/TESTPATH/section1/ntbk.ipynb&amp;branch=master" title="Launch on JupyterHub">
19+
<a class="headerbtn" data-placement="left" data-toggle="tooltip" href="https://datahub.berkeley.edu/hub/user-redirect/git-pull?repo=https%3A//github.com/executablebooks/sphinx-book-theme&amp;urlpath=lab/tree/sphinx-book-theme/TESTPATH/section1/ntbk.ipynb&amp;branch=master" title="Launch on JupyterHub">
2020
<span class="headerbtn__icon-container">
2121
<img src="../_static/images/logo_jupyterhub.svg"/>
2222
</span>

tests/test_build/test_topbar_launchbtns.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</a>
1717
</li>
1818
<li>
19-
<a class="headerbtn" data-placement="left" data-toggle="tooltip" href="https://datahub.berkeley.edu/hub/user-redirect/git-pull?repo=https://github.com/executablebooks/sphinx-book-theme&amp;urlpath=lab/tree/sphinx-book-theme/TESTPATH/section1/ntbk.ipynb&amp;branch=master" title="Launch on JupyterHub">
19+
<a class="headerbtn" data-placement="left" data-toggle="tooltip" href="https://datahub.berkeley.edu/hub/user-redirect/git-pull?repo=https%3A//github.com/executablebooks/sphinx-book-theme&amp;urlpath=lab/tree/sphinx-book-theme/TESTPATH/section1/ntbk.ipynb&amp;branch=master" title="Launch on JupyterHub">
2020
<span class="headerbtn__icon-container">
2121
<img src="../_static/images/logo_jupyterhub.svg"/>
2222
</span>

0 commit comments

Comments
 (0)