Skip to content
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

Guarantee that badge_base_url will always have a trailing / #1779

Merged
merged 1 commit into from
Oct 18, 2023
Merged
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
3 changes: 3 additions & 0 deletions binderhub/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ def get_badge_base_url(self):
badge_base_url = self.settings["badge_base_url"]
if callable(badge_base_url):
badge_base_url = badge_base_url(self)
# Make sure the url has a trailing slash
if not badge_base_url.endswith("/"):
badge_base_url += "/"
return badge_base_url

def render_template(self, name, **extra_ns):
Expand Down
4 changes: 3 additions & 1 deletion binderhub/static/js/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ const badge_base_url = document.getElementById("badge-base-url").dataset.url;
* Base URL to use for both badge images as well as launch links.
*
* If not explicitly set, will default to BASE_URL. Primarily set up different than BASE_URL
* when used as part of a federation
* when used as part of a federation.
*
* Guaranteed to have a trailing slash by the binderhub python configuration.
*/
export const BADGE_BASE_URL = badge_base_url
? new URL(badge_base_url, document.location.origin)
Expand Down
Loading