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

Patrick Mézard pmezard at gmail.com
Tue May 27 16:37:36 CDT 2008


Emanuele Aina a écrit :
> # 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 += '/'

The two other patches are good for me (except I will switch the test and the fix order), but I am less sure about this one. I am really tempted to make "url" always a relative URL instead. Is this issue related to the RSS template only or am I missing something ?

--
Patrick Mézard


More information about the Mercurial-devel mailing list