summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hellkamp <marc@gsites.de>2010-12-14 11:42:34 +0100
committerMarcel Hellkamp <marc@gsites.de>2010-12-14 11:47:47 +0100
commit5396f554f3acc36347e1ad4fdf76f5f9628d5671 (patch)
treeb2c550abb3c6ecd2cce34fa05821faf2c70b4618
parent5002b44dd52691bdee7df00a83cfb8da336b19fc (diff)
downloadbottle-5396f554f3acc36347e1ad4fdf76f5f9628d5671.tar.gz
fix: "Digits cannot be used in route parameter names" (#108)
Thanks to Alexey Borzenkov
-rwxr-xr-xbottle.py2
-rwxr-xr-xtest/test_router.py8
2 files changed, 9 insertions, 1 deletions
diff --git a/bottle.py b/bottle.py
index 8f2be9e..a567eb0 100755
--- a/bottle.py
+++ b/bottle.py
@@ -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