url: detect scheme with a regexp instead of urlsplit()
The latter says 'c' is a scheme in 'c:\foo\bar'
--- 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)