Don't swallow last URL component if it doesn't end in a slash
Closed this issue · 3 comments
I did the equivalent of this:
from urlparse import urljoin
api = Url(urljoin(MY_BASEURL, 'api'))
api.get('foos/123')
and wondered why it gave me a 404 when curl http://${MY_BASEURL}/api/foos/123
worked just fine in the console, but then it dawned on me that the code was actually dropping api
and calling http://${MY_BASEURL}/foos/123
. Adding a slash like this solved the problem:
api = Url(urljoin(MY_BASEURL, 'api/'))
but I think that just doesn't look as good, and the default behavior is kind of surprising. I would find it better for client code if nap would add a slash to the base URL passed to Url()
transparently.
That's a bug. I was under the impression that I had finally created a bug free library :) damn. I added a failing test case for this in this commit: 3ea7b41
Yeah, I also noticed that the same thing happens if MY_BASEURL has a path and you leave out the slash at the end.
–Ilkka
On 16 Nov 2015, at 16:52, Kimmo Brunfeldt notifications@github.com wrote:
That's a bug. I was under the impression that I had finally created a bug free library :) damn. I added a failing test case for this in this commit: 3ea7b41
—
Reply to this email directly or view it on GitHub.
Yes, I just ran into this problem. Is there a potential fix for this on the horizon? I just installed 2.0.0 from PyPI.