##// END OF EJS Templates
url: special case bundle URL parsing to preserve backwards compatibility...
Brodie Rao -
r13816:2540f808 default
parent child Browse files
Show More
@@ -29,6 +29,9 b' class url(object):'
29
29
30 See http://www.ietf.org/rfc/rfc2396.txt for more information.
30 See http://www.ietf.org/rfc/rfc2396.txt for more information.
31
31
32 Note that for backward compatibility reasons, bundle URLs do not
33 take host names. That means 'bundle://../' has a path of '../'.
34
32 Examples:
35 Examples:
33
36
34 >>> url('http://www.ietf.org/rfc/rfc2396.txt')
37 >>> url('http://www.ietf.org/rfc/rfc2396.txt')
@@ -39,6 +42,8 b' class url(object):'
39 <url scheme: 'file', path: '/home/joe/repo'>
42 <url scheme: 'file', path: '/home/joe/repo'>
40 >>> url('bundle:foo')
43 >>> url('bundle:foo')
41 <url scheme: 'bundle', path: 'foo'>
44 <url scheme: 'bundle', path: 'foo'>
45 >>> url('bundle://../foo')
46 <url scheme: 'bundle', path: '../foo'>
42 >>> url('c:\\\\foo\\\\bar')
47 >>> url('c:\\\\foo\\\\bar')
43 <url path: 'c:\\\\foo\\\\bar'>
48 <url path: 'c:\\\\foo\\\\bar'>
44
49
@@ -71,6 +76,16 b' class url(object):'
71 self.path = path
76 self.path = path
72 return
77 return
73
78
79 # For compatibility reasons, we can't handle bundle paths as
80 # normal URLS
81 if path.startswith('bundle:'):
82 self.scheme = 'bundle'
83 path = path[7:]
84 if path.startswith('//'):
85 path = path[2:]
86 self.path = path
87 return
88
74 if not path.startswith('/') and ':' in path:
89 if not path.startswith('/') and ':' in path:
75 parts = path.split(':', 1)
90 parts = path.split(':', 1)
76 if parts[0]:
91 if parts[0]:
@@ -159,11 +174,15 b' class url(object):'
159 'http://localhost:80/'
174 'http://localhost:80/'
160 >>> str(url('bundle:foo'))
175 >>> str(url('bundle:foo'))
161 'bundle:foo'
176 'bundle:foo'
177 >>> str(url('bundle://../foo'))
178 'bundle:../foo'
162 >>> str(url('path'))
179 >>> str(url('path'))
163 'path'
180 'path'
164 """
181 """
165 if self._localpath:
182 if self._localpath:
166 s = self.path
183 s = self.path
184 if self.scheme == 'bundle':
185 s = 'bundle:' + s
167 if self.fragment:
186 if self.fragment:
168 s += '#' + self.fragment
187 s += '#' + self.fragment
169 return s
188 return s
General Comments 0
You need to be logged in to leave comments. Login now