summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-05 16:04:25 +0100
committerDanilo M. <danix@danix.xyz>2026-11-05 16:04:25 +0100
commitf76bd4a8cb3177ff17f7915e275c1f0e3b9e16fa (patch)
tree81089fc0058abdf6816c16d56fca579131a03ac1
parent6fd9c1dd54e32b37fae9affd9b4980270fde5a12 (diff)
downloadcgit-theme-danix-master.tar.gz
cgit-theme-danix-master.zip
fix(head): use the default branch for README imagesHEADmaster
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 <noreply@anthropic.com>
-rw-r--r--head.html5
1 files changed, 3 insertions, 2 deletions
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) : '');
}
});
}