diff options
author | Marcel Hellkamp <marc@gsites.de> | 2010-12-14 11:42:34 +0100 |
---|---|---|
committer | Marcel Hellkamp <marc@gsites.de> | 2010-12-14 11:47:47 +0100 |
commit | 5396f554f3acc36347e1ad4fdf76f5f9628d5671 (patch) | |
tree | b2c550abb3c6ecd2cce34fa05821faf2c70b4618 | |
parent | 5002b44dd52691bdee7df00a83cfb8da336b19fc (diff) | |
download | bottle-5396f554f3acc36347e1ad4fdf76f5f9628d5671.tar.gz |
fix: "Digits cannot be used in route parameter names" (#108)
Thanks to Alexey Borzenkov
-rwxr-xr-x | bottle.py | 2 | ||||
-rwxr-xr-x | test/test_router.py | 8 |
2 files changed, 9 insertions, 1 deletions
@@ -197,7 +197,7 @@ class RouteBuildError(RouteError): class Route(object): ''' Represents a single route and can parse the dynamic route syntax ''' - syntax = re.compile(r'(.*?)(?<!\\):([a-zA-Z_]+)?(?:#(.*?)#)?') + syntax = re.compile(r'(.*?)(?<!\\):([a-zA-Z_][a-zA-Z_0-9]*)?(?:#(.*?)#)?') default = '[^/]+' def __init__(self, route, target=None, name=None, static=False): diff --git a/test/test_router.py b/test/test_router.py index 38c8337..5b17e52 100755 --- a/test/test_router.py +++ b/test/test_router.py @@ -26,6 +26,14 @@ class TestRouter(unittest.TestCase): self.assertEqual(('anon', {}), match('/anon/match')) self.assertEqual((None, {}), match('//no/m/at/ch/')) + def testWildcardNames(self): + add = self.add + match = self.r.match + add('/alpha/:abc', 'abc') + self.assertEqual(('abc', {'abc': 'alpha'}), match('/alpha/alpha')) + add('/alnum/:md5', 'md5') + self.assertEqual(('md5', {'md5': 'sha1'}), match('/alnum/sha1')) + def testParentheses(self): add = self.add match = self.r.match |