diff --git a/src/sphinx_book_theme/header_buttons/launch.py b/src/sphinx_book_theme/header_buttons/launch.py index 51c692b2..c5b220b0 100644 --- a/src/sphinx_book_theme/header_buttons/launch.py +++ b/src/sphinx_book_theme/header_buttons/launch.py @@ -1,5 +1,6 @@ from pathlib import Path from typing import Any, Dict, Optional +from urllib.parse import urlencode from docutils.nodes import document from sphinx.application import Sphinx @@ -118,10 +119,13 @@ def add_launch_buttons( ) if jupyterhub_url: - url = ( - f"{jupyterhub_url}/hub/user-redirect/git-pull?" - f"repo={repo_url}&urlpath={ui_pre}/{repo}/{path_rel_repo}&branch={branch}" + url_params = urlencode( + dict( + repo=repo_url, urlpath=f"{ui_pre}/{repo}/{path_rel_repo}", branch=branch + ), + safe="/", ) + url = f"{jupyterhub_url}/hub/user-redirect/git-pull?{url_params}" launch_buttons_list.append( { "type": "link", diff --git a/tests/test_build/build__header-article.html b/tests/test_build/build__header-article.html index 153bf568..74bc3326 100644 --- a/tests/test_build/build__header-article.html +++ b/tests/test_build/build__header-article.html @@ -27,7 +27,7 @@