Skip to content

Commit

Permalink
Merge pull request #1779 from yuvipanda/base_url_trailing_slash
Browse files Browse the repository at this point in the history
Guarantee that badge_base_url will always have a trailing /
  • Loading branch information
consideRatio authored Oct 18, 2023
2 parents 9f6ea44 + 2b9c13f commit af81d7f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
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

0 comments on commit af81d7f

Please sign in to comment.