diff options
author | Ben Bangert <ben@groovie.org> | 2012-03-12 14:21:19 -0700 |
---|---|---|
committer | Ben Bangert <ben@groovie.org> | 2012-03-12 14:21:19 -0700 |
commit | 6a9febed4b419a5b6ba3e12c52fd75c478cb69f0 (patch) | |
tree | 35b198ed73a1881dfd0cb9a3cdcf99cd3c8c174f | |
parent | 3fb996e9ee529f7305569d423848c2c61ac3def7 (diff) | |
parent | 2922178839bc3e40d31cfb6ae4d4669bf3a73244 (diff) | |
download | routes-6a9febed4b419a5b6ba3e12c52fd75c478cb69f0.tar.gz |
merge
--HG--
branch : trunk
-rw-r--r-- | routes/mapper.py | 4 | ||||
-rw-r--r-- | tests/test_functional/test_resources.py | 22 |
2 files changed, 24 insertions, 2 deletions
diff --git a/routes/mapper.py b/routes/mapper.py index 9befa7d..524c177 100644 --- a/routes/mapper.py +++ b/routes/mapper.py @@ -1082,8 +1082,8 @@ class Mapper(SubMapperParent): self.connect("formatted_" + name_prefix + name, formatted_path, **route_options) self.connect(name_prefix + name, path, **route_options) - - requirements_regexp = '[^\/]+' + + requirements_regexp = '[^\/]+(?<!\\\)' # Add the routes that deal with member methods of a resource for method, lst in member_methods.iteritems(): diff --git a/tests/test_functional/test_resources.py b/tests/test_functional/test_resources.py index 333716b..9fd7ab9 100644 --- a/tests/test_functional/test_resources.py +++ b/tests/test_functional/test_resources.py @@ -127,6 +127,28 @@ class TestResourceRecognition(unittest.TestCase): test_path('/people/2.json', 'PUT') eq_({'controller':'people', 'action':'update', 'id':'2', 'format':'json'}, con.mapper_dict ) + # Test for dots in urls + test_path('/people/2\.13', 'PUT') + eq_({'controller':'people', 'action':'update', 'id':'2\.13'}, con.mapper_dict) + test_path('/people/2\.13.xml', 'PUT') + eq_({'controller':'people', 'action':'update', 'id':'2\.13', 'format':'xml'}, con.mapper_dict) + test_path('/people/user\.name', 'PUT') + eq_({'controller':'people', 'action':'update', 'id':'user\.name'}, con.mapper_dict) + test_path('/people/user\.\.\.name', 'PUT') + eq_({'controller':'people', 'action':'update', 'id':'user\.\.\.name'}, con.mapper_dict) + test_path('/people/user\.name\.has\.dots', 'PUT') + eq_({'controller':'people', 'action':'update', 'id':'user\.name\.has\.dots'}, con.mapper_dict) + test_path('/people/user\.name\.is\.something.xml', 'PUT') + eq_({'controller':'people', 'action':'update', 'id':'user\.name\.is\.something', 'format':'xml'}, con.mapper_dict) + test_path('/people/user\.name\.ends\.with\.dot\..xml', 'PUT') + eq_({'controller':'people', 'action':'update', 'id':'user\.name\.ends\.with\.dot\.', 'format':'xml'}, con.mapper_dict) + test_path('/people/user\.name\.ends\.with\.dot\.', 'PUT') + eq_({'controller':'people', 'action':'update', 'id':'user\.name\.ends\.with\.dot\.'}, con.mapper_dict) + test_path('/people/\.user\.name\.starts\.with\.dot', 'PUT') + eq_({'controller':'people', 'action':'update', 'id':'\.user\.name\.starts\.with\.dot'}, con.mapper_dict) + test_path('/people/user\.name.json', 'PUT') + eq_({'controller':'people', 'action':'update', 'id':'user\.name', 'format':'json'}, con.mapper_dict) + def test_resource_with_nomin(self): m = Mapper() m.minimization = False |