diff options
Diffstat (limited to 'src/mailman/rest/wsgiapp.py')
| -rw-r--r-- | src/mailman/rest/wsgiapp.py | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/mailman/rest/wsgiapp.py b/src/mailman/rest/wsgiapp.py index 70d756405..0be96d42c 100644 --- a/src/mailman/rest/wsgiapp.py +++ b/src/mailman/rest/wsgiapp.py @@ -131,21 +131,21 @@ class ObjectRouter: if matcher is MISSING: continue result = None + + # Is the matcher a regular expression or plain + # string? if isinstance(matcher, str): - # Is the matcher string a regular expression or plain - # string? If it starts with a caret, it's a regexp. - if matcher.startswith('^'): - cre = re.compile(matcher) - # Search against the entire remaining path. - tmp_segments = segments[:] - tmp_segments.insert(0, this_segment) - remaining_path = SLASH.join(tmp_segments) - mo = cre.match(remaining_path) - if mo: - result = attribute( - context, segments, **mo.groupdict()) - elif matcher == this_segment: + if matcher == this_segment: result = attribute(context, segments) + elif isinstance(matcher, re._pattern_type): + # Search against the entire remaining path. + tmp_segments = segments[:] + tmp_segments.insert(0, this_segment) + remaining_path = SLASH.join(tmp_segments) + mo = matcher.match(remaining_path) + if mo: + result = attribute( + context, segments, **mo.groupdict()) else: # The matcher is a callable. It returns None if it # doesn't match, and if it does, it returns a 3-tuple |
