furl
furl copied to clipboard
Triple slashes
Although it is okay, still looks weird:
>>> f = furl('staging.s3-website.us-east-1.amazonaws.com')
>>> f.scheme = 'http'
>>> f.url
'http:///staging.s3-website.us-east-1.amazonaws.com'
Why is there triple slashes?
Additional:
>>> f = furl('http://staging.s3-website.us-east-1.amazonaws.com')
>>> f.url
'http://staging.s3-website.us-east-1.amazonaws.com'
But:
>>> f = furl('staging.s3-website.us-east-1.amazonaws.com')
>>> f.scheme = 'http://' # yes, it's not a proper way, but still confusing how parser works
'http://:staging.s3-website.us-east-1.amazonaws.com'
I'm confused.
see https://github.com/gruns/furl/issues/110 and https://github.com/gruns/furl/issues/103
in short, furl doesn't know whether to treat staging.s3-website.us-east-1.amazonaws.com as a path or a domain, as it can be both. so, to be unambiguous, it treats it as a path, resulting in 'http:///staging.s3-website.us-east-1.amazonaws.com' (with an empty host)
until furl knows the public suffix list (something i started working on but have yet to finish), you can avoid this by explicitly setting 'staging.s3-website.us-east-1.amazonaws.com' as the host, eg
>>> f = furl().set(host='staging.s3-website.us-east-1.amazonaws.com')
>>> f.url
'//staging.s3-website.us-east-1.amazonaws.com'