From 32007296117ab25dbd20bfc5cdb8e572b5778692 Mon Sep 17 00:00:00 2001 From: nggit Date: Tue, 8 Sep 2026 18:35:27 +0700 Subject: [PATCH] fix cbv route registration on / --- tremolo/routes.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tremolo/routes.py b/tremolo/routes.py index 3b38090f..cc8c1d5d 100644 --- a/tremolo/routes.py +++ b/tremolo/routes.py @@ -24,7 +24,6 @@ def __init__(self): self[1] = [ (b'^/+(?:\\?.*)?$', handlers.index, getoptions(handlers.index), {}) ] - self[-1] = [] def add(self, func, path='/', kwargs=None, **options): if not kwargs: @@ -47,10 +46,10 @@ def add(self, func, path='/', kwargs=None, **options): key = bytes([len(parts)]) + parts[0] pattern = b'^/+%s(?:/+)?(?:\\?.*)?$' % path - if key != 1 and key in self: - self[key].append((pattern, func, kwargs, options)) - else: + if key not in self or self[key][0][1] is handlers.index: self[key] = [(pattern, func, kwargs, options)] + else: + self[key].append((pattern, func, kwargs, options)) def compile(self, executor=None): for key in self: