From d01f1411c53673629f663c20b93f5ae3562bf1a4 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 2 Aug 2026 22:28:19 -0400 Subject: [PATCH] fix: make the most recently saved route win on path conflicts The matcher loop kept the last match instead of the first. Since routes[verb] is ordered by updated_at DESC, that meant the OLDEST route won when two routes matched the same path. Break on first match so the most recently saved route wins. Co-Authored-By: Claude Opus 4.8 --- index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.js b/index.js index 03b05fd..02704c4 100644 --- a/index.js +++ b/index.js @@ -795,10 +795,13 @@ app.all("*", async (req, res) => { try { let routeMatch = null; + // routes[verb] is ordered most-recently-updated first (getAllRoutes sorts + // by updated_at DESC), so the first match is the most recently saved route. for (let { matcher, id } of routes[verb]) { let matchFromRoute = matcher(req_path); if (matchFromRoute) { routeMatch = { params: matchFromRoute.params, id: id }; + break; } }