diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-05 16:04:25 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-05 16:04:25 +0100 |
| commit | f76bd4a8cb3177ff17f7915e275c1f0e3b9e16fa (patch) | |
| tree | 81089fc0058abdf6816c16d56fca579131a03ac1 | |
| parent | 6fd9c1dd54e32b37fae9affd9b4980270fde5a12 (diff) | |
| download | cgit-theme-danix-master.tar.gz cgit-theme-danix-master.zip | |
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.html | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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) : ''); } }); } |
