From 0578f1e334d00cb5b15eb1007f7bfdfe62a855b4 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Wed, 24 May 2017 12:13:49 +0300 Subject: [PATCH] Don't allow slashes in Path Templating segments According to https://github.com/OAI/OpenAPI-Specification/issues/892 slashes aren't (yet?) supported in path templating parts, so change the Path class to adhere to that. This fixes a problem where declaring the paths `/api/foo/{id}/` and `/api/foo/{id}/quux/` (in that order) would cause the latter route to never be matched. --- lepo/path.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lepo/path.py b/lepo/path.py index d229d6f..0f40686 100644 --- a/lepo/path.py +++ b/lepo/path.py @@ -30,7 +30,7 @@ def _build_view_name(self): def _build_regex(self): return re.sub( PATH_PLACEHOLDER_REGEX, - lambda m: '(?P<%s>.+?)' % m.group(1), + lambda m: '(?P<%s>[^/]+?)' % m.group(1), self.path, ).lstrip('/') + '$'