From 63fbcc4b54184f0e33ab1ae2e898e7456e5fa8de Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 8 May 2026 13:06:35 +0200 Subject: fix(about): rewrite relative img src to cgit plain/ endpoint README images with relative paths resolve incorrectly on /about/ pages. JS now rewrites them to /REPO/plain/PATH?h=BRANCH on DOMContentLoaded. Co-Authored-By: Claude Sonnet 4.6 --- head.html | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'head.html') diff --git a/head.html b/head.html index 96f3daf..68bda81 100644 --- a/head.html +++ b/head.html @@ -15,5 +15,20 @@ document.addEventListener('DOMContentLoaded', function() { node.textContent = node.textContent.replace(' : ', '/'); } }); + + // Rewrite relative img src in README/about pages to cgit plain/ endpoint + if (/\/about\//.test(window.location.pathname)) { + var m = window.location.pathname.match(/^\/([^/]+)\/about\//); + if (m) { + var repo = m[1]; + var branch = (new URLSearchParams(window.location.search)).get('h') || 'main'; + 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; + } + }); + } + } }); -- cgit v1.2.3