diff options
| -rw-r--r-- | pyramid/tests/test_urldispatch.py | 4 | ||||
| -rw-r--r-- | pyramid/urldispatch.py | 6 |
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 = [] |
