grim/hgwebplus

Parents 571f423e55a8
Children c358fb7b1ca2
Fix a bug where absolute URLs for images were being treated as relative URLs.
--- a/ChangeLog Sun May 17 17:16:03 2020 -0500
+++ b/ChangeLog Sun May 17 23:14:57 2020 -0500
@@ -1,5 +1,5 @@
0.5.3:
- * Nothing yet, be the first!!
+ * Don't treat absolute image URL's as relative URL's.
0.5.2: (2020-05-17)
* Updated the readme for the sub_title template keyword.
--- a/src/hgwebplus.py Sun May 17 17:16:03 2020 -0500
+++ b/src/hgwebplus.py Sun May 17 23:14:57 2020 -0500
@@ -31,6 +31,8 @@
from mercurial.hgweb import webutil, hgweb_mod
from mercurial.hgweb.common import paritygen
+from urllib.parse import urlparse
+
import mistune
from mistune.directives import DirectiveToc
@@ -265,7 +267,8 @@
class Renderer(mistune.HTMLRenderer):
def image(self, src, alt, title):
- src = 'rawfile/%s/%s' % (ctx.rev(), src)
+ if urlparse(src).netloc == '':
+ src = 'rawfile/%s/%s' % (ctx.rev(), src)
return super().image(src, alt, title)