diff options
| -rw-r--r-- | head.html | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -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; + } + }); + } + } }); </script> |
