Skip to content

Commit

Permalink
Don't allow slashes in Path Templating segments
Browse files Browse the repository at this point in the history
According to OAI/OpenAPI-Specification#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.
  • Loading branch information
akx committed Jul 31, 2017
1 parent bc73c2d commit 0578f1e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lepo/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('/') + '$'

Expand Down

0 comments on commit 0578f1e

Please sign in to comment.