From c4d28b9207cc53b28c5aa3d2a7ac4fa810225105 Mon Sep 17 00:00:00 2001 From: Carlos Polop Date: Sat, 4 Jul 2026 13:35:45 +0200 Subject: [PATCH] Support absolute sponsor image URLs --- theme/sponsor.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/theme/sponsor.js b/theme/sponsor.js index 337740dab..6e54e2614 100644 --- a/theme/sponsor.js +++ b/theme/sponsor.js @@ -107,8 +107,30 @@ return "" } + function resolveSponsorImageUrl(imageUrl) { + var value = String(imageUrl || "").trim() + + if (!value) { + return "" + } + + if (/^https:\/\//i.test(value)) { + return value + } + + if (/^\/\//.test(value)) { + return "https:" + value + } + + if (value.charAt(0) === "/") { + return new URL(value, window.location.origin).href + } + + return new URL(value, document.baseURI || window.location.href).href + } + function setLegacySponsorContent(sponsor, container, nodes) { - nodes.img.src = sponsor.image_url + nodes.img.src = resolveSponsorImageUrl(sponsor.image_url) nodes.img.alt = sponsor.name nodes.title.textContent = sponsor.name nodes.description.innerHTML = sponsor.description