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
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
Guarantee that badge_base_url will always have a trailing /
Before this, the callable could return something without a
trailing slash, and that could break things.
yuvipanda committed Oct 16, 2023
commit 2b9c13f2cf2b2bf9973e30f06bfa883a90caa8eb
3 changes: 3 additions & 0 deletions binderhub/base.py
Original file line number Diff line number Diff line change
@@ -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):
4 changes: 3 additions & 1 deletion binderhub/static/js/src/constants.js
Original file line number Diff line number Diff line change
@@ -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)