diff Lib/urlparse.py @ 2047:f18c1915c722 legacy-trunk

Add hacks for switching protocol and path but leaving host unchanged
author Guido van Rossum <guido@python.org>
date Fri, 30 Dec 1994 17:18:59 +0000
parents 8c9cc054c5ed
children 0acbd85bcdba
line wrap: on
line diff
--- a/Lib/urlparse.py	Fri Dec 30 17:17:46 1994 +0000
+++ b/Lib/urlparse.py	Fri Dec 30 17:18:59 1994 +0000
@@ -88,6 +88,18 @@
 		  urlparse(base, '', allow_framents)
 	scheme, netloc, path, params, query, fragment = \
 		urlparse(url, bscheme, allow_framents)
+	# XXX Unofficial hack: default netloc to bnetloc even if
+	# schemes differ
+	if scheme != bscheme and not netloc and \
+	   scheme in uses_relative and bscheme in uses_relative and \
+	   scheme in uses_netloc and bscheme in uses_netloc:
+	   netloc = bnetloc
+	   # Strip the port number
+	   i = string.find(netloc, '@')
+	   if i < 0: i = 0
+	   i = string.find(netloc, ':', i)
+	   if i >= 0:
+		   netloc = netloc[:i]
 	if scheme != bscheme or scheme not in uses_relative:
 		return urlunparse((scheme, netloc, path,
 				   params, query, fragment))