diff --git a/endpoints/api_config_manager.py b/endpoints/api_config_manager.py index 3512702..525a876 100644 --- a/endpoints/api_config_manager.py +++ b/endpoints/api_config_manager.py @@ -317,11 +317,7 @@ def replace_variable(match): pattern = re.sub('(/|^){(%s)}(?=/|$|:)' % _PATH_VARIABLE_PATTERN, replace_variable, pattern) - if pattern.endswith('/'): - pattern += '?$' - else: - pattern += '/?$' - return re.compile(pattern) + return re.compile(pattern + '/?$') def _save_rpc_method(self, method_name, version, method): """Store JsonRpc api methods in a map for lookup at call time. diff --git a/endpoints/test/api_config_manager_test.py b/endpoints/test/api_config_manager_test.py index 37a9694..9a45e07 100644 --- a/endpoints/test/api_config_manager_test.py +++ b/endpoints/test/api_config_manager_test.py @@ -264,26 +264,6 @@ def test_trailing_slash_optional(self): self.assertEqual(fake_method, method_spec) self.assertEqual({}, params) - def test_trailing_slash_could_be_omitted(self): - # Create a get resource URL with trailing slash. - fake_method = {'httpMethod': 'GET', 'path': 'with-trailing-slash/'} - self.config_manager._save_rest_method('guestbook_api.withtrailingslash', - 'guestbook_api', 'v1', fake_method) - - # Make sure we get the method when we query with a slash. - method_name, method_spec, params = self.config_manager.lookup_rest_method( - 'guestbook_api/v1/with-trailing-slash/', 'GET') - self.assertEqual('guestbook_api.withtrailingslash', method_name) - self.assertEqual(fake_method, method_spec) - self.assertEqual({}, params) - - # Make sure we get the method when we query without a slash. - method_name, method_spec, params = self.config_manager.lookup_rest_method( - 'guestbook_api/v1/with-trailing-slash', 'GET') - self.assertEqual('guestbook_api.withtrailingslash', method_name) - self.assertEqual(fake_method, method_spec) - self.assertEqual({}, params) - class ParameterizedPathTest(unittest.TestCase):