Bug in the urljoin library
Peter Otten
__peter__ at web.de
Tue Apr 28 13:10:31 EDT 2020
Moro, Andrea via Python-list wrote:
> Hello there,
>
> I believe there is a bug in the urljoin library.
I believe this is a case of garbage-in garbage-out ;)
Try
p = urlparse(url)
if not p.scheme:
url = urlunparse(p._replace(scheme="http"))
>
> See below:
>
> p = urlparse(url)
> if p.scheme == '':
> url = urljoin('http://', url)
>
>
> Input:
> domain.tld/somepath
>
> Output
> http:///domain.tld/somepath
>
> p = urlparse(url)
> if p.scheme == '':
> url = urljoin('http:', url)
>
> Input:
> domain.tld/somepath
>
> Output
> http:///domain.tld/somepath
>
More information about the Python-list
mailing list