summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2011-05-30 00:37:45 -0700
committerChris McDonough <chrism@plope.com>2011-05-30 00:37:45 -0700
commitbf08b3bf5b7b3b8fc5c3c9f3618a30e13ee5d7bb (patch)
tree5f45cc101a3e7de74da520c936c55b886fbce55f
parent8f521b387bcf28c9819c753856e33d1d782d3645 (diff)
parentb2eb18ff11a691ad9b5909293d58b014fcb5ef43 (diff)
downloadpyramid-bf08b3bf5b7b3b8fc5c3c9f3618a30e13ee5d7bb.tar.gz
pyramid-bf08b3bf5b7b3b8fc5c3c9f3618a30e13ee5d7bb.tar.bz2
pyramid-bf08b3bf5b7b3b8fc5c3c9f3618a30e13ee5d7bb.zip
Merge pull request #198 from mmerickel/fix_wildcard_dispatch
Fixed a bug in dispatch matching * at the end of a route.
-rw-r--r--pyramid/tests/test_urldispatch.py4
-rw-r--r--pyramid/urldispatch.py6
2 files changed, 7 insertions, 3 deletions
diff --git a/pyramid/tests/test_urldispatch.py b/pyramid/tests/test_urldispatch.py
index 7df237aeb..ec45cb71e 100644
--- a/pyramid/tests/test_urldispatch.py
+++ b/pyramid/tests/test_urldispatch.py
@@ -366,6 +366,10 @@ class TestCompileRouteMatchFunctional(unittest.TestCase):
self.matches('*traverse', '/La%20Pe%C3%B1a/x',
{'traverse':(u'La Pe\xf1a', 'x')})
self.matches('/foo/:id.html', '/foo/bar.html', {'id':'bar'})
+ self.matches('/{num:[0-9]+}/*traverse', '/555/abc/def',
+ {'num':'555', 'traverse':('abc', 'def')})
+ self.matches('/{num:[0-9]*}/*traverse', '/555/abc/def',
+ {'num':'555', 'traverse':('abc', 'def')})
def test_generator_functional(self):
self.generates('', {}, '/')
diff --git a/pyramid/urldispatch.py b/pyramid/urldispatch.py
index 43bc7e50f..230b18e54 100644
--- a/pyramid/urldispatch.py
+++ b/pyramid/urldispatch.py
@@ -77,7 +77,7 @@ class RoutesMapper(object):
# stolen from bobo and modified
old_route_re = re.compile(r'(\:[a-zA-Z]\w*)')
-star_in_brackets = re.compile(r'\{[^\}]*\*\w*[^\}]*\}')
+star_at_end = re.compile(r'\*\w*$')
# The torturous nature of the regex named ``route_re`` below is due to the
# fact that we need to support at least one level of "inner" squigglies
@@ -97,9 +97,9 @@ def _compile_route(route):
route = '/' + route
star = None
-
- if '*' in route and not star_in_brackets.search(route):
+ if star_at_end.search(route):
route, star = route.rsplit('*', 1)
+
pat = route_re.split(route)
pat.reverse()
rpat = []