Only define remainder when not empty

I had an issue using a post method on a /path/ since get_args will set
me up with a first empty argument of an empty string and eat my first
argument with it.

Change-Id: Ieb2f192127c1fca430f1376e5bdb2be863fe6920
This commit is contained in:
Chmouel Boudjnah
2014-10-28 13:36:54 +01:00
parent c7f241fd6b
commit 611272a89c
2 changed files with 6 additions and 1 deletions

View File

@@ -344,7 +344,7 @@ class PecanBase(object):
return unquote_plus(x) if isinstance(x, six.string_types) \
else x
remainder = [_decode(x) for x in remainder]
remainder = [_decode(x) for x in remainder if x]
if im_self is not None:
args.append(im_self)

View File

@@ -928,6 +928,11 @@ class TestControllerArguments(PecanTestCase):
assert r.status_int == 200
assert r.body == b_('eater: 9, None, day=12, month=1')
def test_post_empty_remainder_with_json_kwargs(self):
r = self.app_.post_json('/eater/9/', {'month': '1', 'day': '12'})
assert r.status_int == 200
assert r.body == b_('eater: 9, None, day=12, month=1')
def test_post_remainder_with_json_kwargs(self):
r = self.app_.post_json('/eater/9', {'month': '1', 'day': '12'})
assert r.status_int == 200