From 8d09ff429904811cb9fef2794edabd0ecbd88e4f Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 8 Apr 2025 23:50:53 +0200 Subject: [PATCH] fix(routes): remove unused wildcard in apiRoute "/api/options/:name/:value*" the updateOption function that handles the req.param is just destructuring `const { name, value } = req.params;` and does nothing else with the path or any params. The remaining parts of the wildcard (which can be accessed via req.param[0]) are just ignored here. even with express v4, this would *always* just take and process the very first part of the path, in the exact wildcard's place, e.g. `/api/options/locale/de` and `/api/options/locale/de/test/whatever` would *both* end up destructuring "value" from req.param as "de" (because it is in the exact place of the 'value' wildcard) in express v5 the wildcard behaviour changes -> here req.param.value would return an array with the paths split into separate string. but since the code previously regarded only the first part of the path -> we can just get rid of the wildcard and use a named route param the only thing to keep in mind: if a request with more than one "value" is received, (e.g. `/api/options/locale/de/test/whatever`) -> since we don't have the wildcard anymore -> this will turn to a 404. IMHO that is actually desirable here though --- src/routes/routes.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/routes.ts b/src/routes/routes.ts index 25a48a742..37bca7988 100644 --- a/src/routes/routes.ts +++ b/src/routes/routes.ts @@ -238,7 +238,7 @@ function register(app: express.Application) { apiRoute(GET, "/api/options", optionsApiRoute.getOptions); // FIXME: possibly change to sending value in the body to avoid host of HTTP server issues with slashes - apiRoute(PUT, "/api/options/:name/:value*", optionsApiRoute.updateOption); + apiRoute(PUT, "/api/options/:name/:value", optionsApiRoute.updateOption); apiRoute(PUT, "/api/options", optionsApiRoute.updateOptions); apiRoute(GET, "/api/options/user-themes", optionsApiRoute.getUserThemes); apiRoute(GET, "/api/options/codeblock-themes", optionsApiRoute.getSyntaxHighlightingThemes);