url: detect scheme with a regexp instead of urlsplit()
authorPatrick Mezard <pmezard@gmail.com>
Tue, 28 Oct 2008 23:54:01 +0100
changeset 7285 5ad99abfab79
parent 7284 ac81ffac0f35
child 7286 a1f8ad3c1821
url: detect scheme with a regexp instead of urlsplit() The latter says 'c' is a scheme in 'c:\foo\bar'
mercurial/url.py
--- a/mercurial/url.py	Tue Oct 28 22:24:41 2008 +0100
+++ b/mercurial/url.py	Tue Oct 28 23:54:01 2008 +0100
@@ -298,8 +298,13 @@
     opener.addheaders.append(('Accept', 'application/mercurial-0.1'))
     return opener
 
+scheme_re = re.compile(r'^([a-zA-Z0-9+-.]+)://')
+
 def open(ui, url, data=None):
-    scheme = urlparse.urlsplit(url)[0]
+    scheme = None
+    m = scheme_re.search(url)
+    if m:
+        scheme = m.group(1).lower()
     if not scheme:
         path = util.normpath(os.path.abspath(url))
         url = 'file://' + urllib.pathname2url(path)