mercurial/hgweb/hgwebdir_mod.py
changeset 31482 da7d19324b1e
parent 30766 d7bf7d2bd5ab
child 32004 bd3cb917761a
--- a/mercurial/hgweb/hgwebdir_mod.py	Fri Mar 17 09:19:56 2017 -0700
+++ b/mercurial/hgweb/hgwebdir_mod.py	Sun Mar 05 22:22:32 2017 -0500
@@ -254,13 +254,21 @@
                 return []
 
             # top-level index
-            elif not virtual:
+
+            repos = dict(self.repos)
+
+            if not virtual or (virtual == 'index' and virtual not in repos):
                 req.respond(HTTP_OK, ctype)
                 return self.makeindex(req, tmpl)
 
             # nested indexes and hgwebs
 
-            repos = dict(self.repos)
+            if virtual.endswith('/index') and virtual not in repos:
+                subdir = virtual[:-len('index')]
+                if any(r.startswith(subdir) for r in repos):
+                    req.respond(HTTP_OK, ctype)
+                    return self.makeindex(req, tmpl, subdir)
+
             virtualrepo = virtual
             while virtualrepo:
                 real = repos.get(virtualrepo)
@@ -352,8 +360,7 @@
                             pass
 
                 parts = [name]
-                if 'PATH_INFO' in req.env:
-                    parts.insert(0, req.env['PATH_INFO'].rstrip('/'))
+                parts.insert(0, '/' + subdir.rstrip('/'))
                 if req.env['SCRIPT_NAME']:
                     parts.insert(0, req.env['SCRIPT_NAME'])
                 url = re.sub(r'/+', '/', '/'.join(parts) + '/')