diff mercurial/hgweb/hgwebdir_mod.py @ 9184:f6eb03027411

Fix issue1679: path reconstruction in hgwebdir was mangling things badly
author Bryan O'Sullivan <bos@serpentine.com>
date Wed, 22 Jul 2009 15:26:27 -0700
parents 580a79dde2a3
children 8635b33eaade
line wrap: on
line diff
--- a/mercurial/hgweb/hgwebdir_mod.py	Wed Jul 22 22:50:34 2009 +0200
+++ b/mercurial/hgweb/hgwebdir_mod.py	Wed Jul 22 15:26:27 2009 -0700
@@ -6,7 +6,7 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2, incorporated herein by reference.
 
-import os, time
+import os, re, time
 from mercurial.i18n import _
 from mercurial import ui, hg, util, templater
 from mercurial import error, encoding
@@ -225,7 +225,9 @@
                     parts.insert(0, req.env['PATH_INFO'].rstrip('/'))
                 if req.env['SCRIPT_NAME']:
                     parts.insert(0, req.env['SCRIPT_NAME'])
-                url = ('/'.join(parts).replace("//", "/")) + '/'
+                m = re.match('((?:https?://)?)(.*)', '/'.join(parts))
+                # squish repeated slashes out of the path component
+                url = m.group(1) + re.sub('/+', '/', m.group(2)) + '/'
 
                 # update time with local timezone
                 try: