diff --git a/src/turbosloth/router.py b/src/turbosloth/router.py index e9817a1..c125180 100644 --- a/src/turbosloth/router.py +++ b/src/turbosloth/router.py @@ -42,8 +42,8 @@ class Route: if '}' not in part: raise ValueError(f'Invalid subpath substitute placeholder: {part}') re_part = part.replace('(', '\\(').replace(')', '\\)') - names = re.findall(r'\{(.*)}', part) - re_part = re.sub(r'\{.*}', r'(.*)', re_part) + names = re.findall(r'\{(.*?)}', part) + re_part = re.sub(r'\{.*?}', r'(.*?)', re_part) re_part = re.compile('^' + re_part + '$') d = self._find_regexp_subroute(re_part) @@ -100,10 +100,12 @@ class Router: def add(self, method: MethodType, path_pattern: str, handler: InternalHandlerType) -> None: method = typing.cast(MethodType, method.upper()) - substitutes = re.findall(r'\{(.*)}', path_pattern) + substitutes = re.findall(r'\{(.*?)}', path_pattern) if len(substitutes) > 0: subst = [] for s in substitutes: + if isinstance(s, str): + s = [s] subst += list(s) if len(subst) != len(set(subst)): raise ValueError('Duplicate path substitute names are prohibited')