diff options
author | Guido van Rossum <guido@python.org> | 1994-12-30 17:18:59 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1994-12-30 17:18:59 (GMT) |
commit | a1124700f80db19ff02d98f4de4303496c0d203a (patch) | |
tree | a7131d35a48466301ae6e19c524c1f26775f868a /Lib/urlparse.py | |
parent | eecf035aa209cedb4ede08b527120ba3946a0c96 (diff) | |
download | cpython-a1124700f80db19ff02d98f4de4303496c0d203a.zip cpython-a1124700f80db19ff02d98f4de4303496c0d203a.tar.gz cpython-a1124700f80db19ff02d98f4de4303496c0d203a.tar.bz2 |
Add hacks for switching protocol and path but leaving host unchanged
Diffstat (limited to 'Lib/urlparse.py')
-rw-r--r-- | Lib/urlparse.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/urlparse.py b/Lib/urlparse.py index 37fe62a..9fce0bd 100644 --- a/Lib/urlparse.py +++ b/Lib/urlparse.py @@ -88,6 +88,18 @@ def urljoin(base, url, allow_framents = 1): 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)) |