From b6792b00aebbe08f0fa3a4cb7826075114f717fa Mon Sep 17 00:00:00 2001 From: Axel Duch Date: Fri, 10 Jul 2020 10:28:53 +0100 Subject: Router: route patterns multi wildcards fix. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Matching 'start' and 'end' position now adjusted to avoid false matching. This is related to #434 issue on Github. Thanks to 洪志道 (Hong Zhi Dao). --- test/test_routing.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test') diff --git a/test/test_routing.py b/test/test_routing.py index 8a196e88..269e8efc 100644 --- a/test/test_routing.py +++ b/test/test_routing.py @@ -200,6 +200,27 @@ class TestRouting(TestApplicationProto): self.assertEqual(self.get(url='/blah')['status'], 200, '/blah') self.assertEqual(self.get(url='/BLAH')['status'], 404, '/BLAH') + def test_route_match_wildcards_ordered(self): + self.route_match({"uri": "/a*x*y*"}) + + self.assertEqual(self.get(url='/axy')['status'], 200, '/axy') + self.assertEqual(self.get(url='/ayx')['status'], 404, '/ayx') + + def test_route_match_wildcards_adjust_start(self): + self.route_match({"uri": "/bla*bla*"}) + + self.assertEqual(self.get(url='/bla_foo')['status'], 404, '/bla_foo') + + def test_route_match_wildcards_adjust_start_substr(self): + self.route_match({"uri": "*bla*bla*"}) + + self.assertEqual(self.get(url='/bla_foo')['status'], 404, '/bla_foo') + + def test_route_match_wildcards_adjust_end(self): + self.route_match({"uri": "/bla*bla"}) + + self.assertEqual(self.get(url='/foo_bla')['status'], 404, '/foo_bla') + def test_routes_match_wildcard_right_case_sensitive(self): self.route_match({"uri": "/bla*"}) -- cgit