[PATCH 3 of 4 stable] hgweb: make code to join url path simpler (was issue1679)

Yuya Nishihara yuya at tcha.org
Wed Mar 10 09:33:31 CST 2010


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1268234911 -32400
# Branch stable
# Node ID cb34244bd470f10d5ab3023918d06204af004696
# Parent  afe01d51ccc176baeebc3afc970d29b6c0289ea8
hgweb: make code to join url path simpler (was issue1679)

Now SCRIPT_NAME never contains http://host:port part,
we don't need to care about '://'.

diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py
--- a/mercurial/hgweb/hgwebdir_mod.py
+++ b/mercurial/hgweb/hgwebdir_mod.py
@@ -229,9 +229,7 @@ class hgwebdir(object):
                     parts.insert(0, req.env['PATH_INFO'].rstrip('/'))
                 if req.env['SCRIPT_NAME']:
                     parts.insert(0, req.env['SCRIPT_NAME'])
-                m = re.match('((?:https?://)?)(.*)', '/'.join(parts))
-                # squish repeated slashes out of the path component
-                url = m.group(1) + re.sub('/+', '/', m.group(2)) + '/'
+                url = re.sub(r'/+', '/', '/'.join(parts) + '/')
 
                 # update time with local timezone
                 try:


More information about the Mercurial-devel mailing list