[PATCH 3 of 3] Leave urlbase empty in templates if url is already absolute

Emanuele Aina em at nerd.ocracy.org
Wed May 7 12:09:28 UTC 2008


# HG changeset patch
# User Emanuele Aina <em at nerd.ocracy.org>
# Date 1209982626 -7200
# Node ID cc29e71e8dd31615e4f15da6a4f3c9e3c4e33b09
# Parent  95525b4e8e2bbfd245b9aa4f7c1400a4b181cafd
Leave urlbase empty in templates if url is already absolute

diff -r 95525b4e8e2b -r cc29e71e8dd3 mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py	Fri May 02 21:59:26 2008 +0200
+++ b/mercurial/hgweb/hgweb_mod.py	Mon May 05 12:17:06 2008 +0200
@@ -225,7 +225,11 @@
 
         port = req.env["SERVER_PORT"]
         port = port != default_port and (":" + port) or ""
-        urlbase = '%s://%s%s' % (proto, req.env['SERVER_NAME'], port)
+        # if the url is already absolute leave urlbase empty
+        if req.url.startswith(proto+"://"):
+            urlbase = ''
+        else:
+            urlbase = '%s://%s%s' % (proto, req.env['SERVER_NAME'], port)
         staticurl = self.config("web", "staticurl") or req.url + 'static/'
         if not staticurl.endswith('/'):
             staticurl += '/'





More information about the Mercurial-devel mailing list