changeset 36902:e473a032f38a

hgweb: rewrite path generation for index entries I think this code is easier to read. But the real reason to do this is to eliminate a consumer of wsgirequest. Differential Revision: https://phab.mercurial-scm.org/D2824
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 11 Mar 2018 15:15:02 -0700
parents 006165d4d7e2
children 803e0fc0cc9a
files mercurial/hgweb/hgwebdir_mod.py
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/hgwebdir_mod.py	Sun Mar 11 15:08:36 2018 -0700
+++ b/mercurial/hgweb/hgwebdir_mod.py	Sun Mar 11 15:15:02 2018 -0700
@@ -9,7 +9,6 @@
 from __future__ import absolute_import
 
 import os
-import re
 import time
 
 from ..i18n import _
@@ -161,11 +160,12 @@
                 except (IOError, error.RepoError):
                     pass
 
-        parts = [name]
-        parts.insert(0, '/' + subdir.rstrip('/'))
-        if wsgireq.env['SCRIPT_NAME']:
-            parts.insert(0, wsgireq.env['SCRIPT_NAME'])
-        url = re.sub(r'/+', '/', '/'.join(parts) + '/')
+        parts = [
+            wsgireq.req.apppath.strip('/'),
+            subdir.strip('/'),
+            name.strip('/'),
+        ]
+        url = '/' + '/'.join(p for p in parts if p) + '/'
 
         # show either a directory entry or a repository
         if directory: