Skip to content
This repository was archived by the owner on Apr 19, 2026. It is now read-only.

Commit 74ee5fb

Browse files
committed
Revert "Make trailing slash truly optional." (#145)
Squashed commit of the following: commit 7fd92d3 Author: Rose Davidson <rhd@google.com> Date: Tue Mar 13 11:35:36 2018 -0700 Revert "Make trailing slash truly optional. (#142) (#143)" This reverts commit 818c925. Reverted because the author told me he'd found this produces parsing issues: > It seems now patterns like /prefix/{var1}/{var2}/ and /prefix/{var1}/ are mixed up. May reconsider this approach later.
1 parent 818c925 commit 74ee5fb

2 files changed

Lines changed: 1 addition & 25 deletions

File tree

endpoints/api_config_manager.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,7 @@ def replace_variable(match):
317317

318318
pattern = re.sub('(/|^){(%s)}(?=/|$|:)' % _PATH_VARIABLE_PATTERN,
319319
replace_variable, pattern)
320-
if pattern.endswith('/'):
321-
pattern += '?$'
322-
else:
323-
pattern += '/?$'
324-
return re.compile(pattern)
320+
return re.compile(pattern + '/?$')
325321

326322
def _save_rpc_method(self, method_name, version, method):
327323
"""Store JsonRpc api methods in a map for lookup at call time.

endpoints/test/api_config_manager_test.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -264,26 +264,6 @@ def test_trailing_slash_optional(self):
264264
self.assertEqual(fake_method, method_spec)
265265
self.assertEqual({}, params)
266266

267-
def test_trailing_slash_could_be_omitted(self):
268-
# Create a get resource URL with trailing slash.
269-
fake_method = {'httpMethod': 'GET', 'path': 'with-trailing-slash/'}
270-
self.config_manager._save_rest_method('guestbook_api.withtrailingslash',
271-
'guestbook_api', 'v1', fake_method)
272-
273-
# Make sure we get the method when we query with a slash.
274-
method_name, method_spec, params = self.config_manager.lookup_rest_method(
275-
'guestbook_api/v1/with-trailing-slash/', 'GET')
276-
self.assertEqual('guestbook_api.withtrailingslash', method_name)
277-
self.assertEqual(fake_method, method_spec)
278-
self.assertEqual({}, params)
279-
280-
# Make sure we get the method when we query without a slash.
281-
method_name, method_spec, params = self.config_manager.lookup_rest_method(
282-
'guestbook_api/v1/with-trailing-slash', 'GET')
283-
self.assertEqual('guestbook_api.withtrailingslash', method_name)
284-
self.assertEqual(fake_method, method_spec)
285-
self.assertEqual({}, params)
286-
287267

288268
class ParameterizedPathTest(unittest.TestCase):
289269

0 commit comments

Comments
 (0)