changeset 15074:64fbd0de9773 stable

url: parse fragments first (issue2997)
author Matt Mackall <mpm@selenic.com>
date Sat, 10 Sep 2011 17:49:19 -0500
parents 19071b04c9c1
children 77325c92db95
files mercurial/util.py
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util.py	Fri Sep 09 14:41:22 2011 -0500
+++ b/mercurial/util.py	Sat Sep 10 17:49:19 2011 -0500
@@ -1434,6 +1434,8 @@
     <url path: 'c:\\foo\\bar'>
     >>> url(r'\\blah\blah\blah')
     <url path: '\\\\blah\\blah\\blah'>
+    >>> url(r'\\blah\blah\blah#baz')
+    <url path: '\\\\blah\\blah\\blah', fragment: 'baz'>
 
     Authentication credentials:
 
@@ -1462,6 +1464,11 @@
         self._hostport = ''
         self._origpath = path
 
+        if parsefragment and '#' in path:
+            path, self.fragment = path.split('#', 1)
+            if not path:
+                path = None
+
         # special case for Windows drive letters and UNC paths
         if hasdriveletter(path) or path.startswith(r'\\'):
             self.path = path
@@ -1489,10 +1496,6 @@
                 self.path = ''
                 return
         else:
-            if parsefragment and '#' in path:
-                path, self.fragment = path.split('#', 1)
-                if not path:
-                    path = None
             if self._localpath:
                 self.path = path
                 return