You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Bruce Atherton <br...@callenish.com> on 2002/02/12 22:06:59 UTC

Re: Python's urlparse.urljoin() (was: Re: Subversion portability)

At 12:35 PM 2/12/2002 -0800, Greg Stein wrote:
>If anybody can come up with a patch for urlparse.py, then I can check it
>into Python itself :-)

At first, I thought the problem was that the file scheme is in the list of 
schemes that use the network host name part of a URL, but a file URL does 
no such thing. Or does it? Can an NFS server or netware server to be 
specified as file://nfs.mydomain.com/path/to/file.txt, for example?

Apparently it can:
     http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/dist/src/Lib/urlparse.py?rev=1.18&content-type=text/vnd.viewcvs-markup

So if this is correct, the real change belongs in urlunsplit(). I believe 
this patch is correct:

Log:
* urlparse (urlunsplit): Correct test for prepending a "//" to a URL. This 
fixes file URLs so that they unparse as "file:///path/to/file" rather than 
"file:/path/to/file".

Index: urlparse.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/urlparse.py,v
retrieving revision 1.31
diff -u -r1.31 urlparse.py
--- urlparse.py 16 Nov 2001 02:52:57 -0000      1.31
+++ urlparse.py 12 Feb 2002 21:54:04 -0000
@@ -126,7 +126,7 @@
      return urlunsplit((scheme, netloc, url, query, fragment))

  def urlunsplit((scheme, netloc, url, query, fragment)):
-    if netloc or (scheme in uses_netloc and url[:2] == '//'):
+    if netloc or (scheme in uses_netloc and url[:2] != '//'):
          if url and url[:1] != '/': url = '/' + url
          url = '//' + (netloc or '') + url
      if scheme: