Created
June 28, 2015 21:55
-
-
Save medwards/be80a7a9ea64eda60009 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urlparse | |
host = 'http://example.com' | |
endpoint = 'endpoint' | |
thing_id = 226 | |
print "naive urljoin: ", urlparse.urljoin(host, endpoint, thing_id) | |
print "less naive urljoin: ", urlparse.urljoin(urlparse.urljoin(host, endpoint), str(thing_id)) | |
print "ugly working urljoin: ", urlparse.urljoin(host, "%s/%s" % (endpoint, thing_id)) | |
""" | |
naive urljoin: http://example.com/endpoint | |
less naive urljoin: http://example.com/226 | |
ugly working urljoin: http://example.com/endpoint/226 | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment