From 611272a89c0965aa0a311399f1edf9ead7c5d285 Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Tue, 28 Oct 2014 13:36:54 +0100 Subject: 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 --- pecan/core.py | 2 +- pecan/tests/test_base.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pecan/core.py b/pecan/core.py index 49c7e8e..4a2c9be 100644 --- a/pecan/core.py +++ b/pecan/core.py @@ -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) diff --git a/pecan/tests/test_base.py b/pecan/tests/test_base.py index b22b2c8..a18981c 100644 --- a/pecan/tests/test_base.py +++ b/pecan/tests/test_base.py @@ -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 -- cgit v1.2.1