From f76bd4a8cb3177ff17f7915e275c1f0e3b9e16fa Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Thu, 5 Nov 2026 16:04:25 +0100 Subject: fix(head): use the default branch for README images The rewrite to plain/ assumed main when the page had no ?h=, so repositories on master got a 404 for every relative image in their README. Co-Authored-By: Claude Opus 5.5 --- head.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'head.html') diff --git a/head.html b/head.html index 8f1b96b..5b1f413 100644 --- a/head.html +++ b/head.html @@ -21,11 +21,12 @@ document.addEventListener('DOMContentLoaded', function() { var m = window.location.pathname.match(/^\/([^/]+)\/about\//); if (m) { var repo = m[1]; - var branch = (new URLSearchParams(window.location.search)).get('h') || 'main'; + // No ?h= on the page: leave it out too, so cgit uses the repository's default branch. + var branch = (new URLSearchParams(window.location.search)).get('h'); document.querySelectorAll('div#summary img').forEach(function(img) { var src = img.getAttribute('src'); if (src && !/^https?:\/\//.test(src) && !/^\//.test(src)) { - img.src = '/' + repo + '/plain/' + src + '?h=' + branch; + img.src = '/' + repo + '/plain/' + src + (branch ? '?h=' + encodeURIComponent(branch) : ''); } }); } -- cgit v1.2.3