fix: ensure typescript routes are hit most to least specific

This commit is contained in:
Andy Burke 2025-06-25 20:24:51 -07:00
parent 4f68a64a88
commit 1928bfcb5e
6 changed files with 35 additions and 12 deletions

View file

@ -96,7 +96,7 @@ export default async function handle_typescript(request: Request): Promise<Respo
const pattern = new URLPattern({ pathname: import_info.route_path });
if (Deno.env.get('SERVERUS_TYPESCRIPT_IMPORT_LOGGING')) {
console.log(`imported: ${import_info.import_path}`);
console.log(`${import_info.route_path} : imported: ${import_info.import_path}`);
}
routes.set(pattern, module);
@ -115,7 +115,7 @@ export default async function handle_typescript(request: Request): Promise<Respo
}
for (const [pattern, handler_module] of routes) {
const match = pattern.exec(request.url);
const match = pattern.exec(request.url.replace(/\/$/, ''));
if (match) {
const method = request.method as keyof ROUTE_HANDLER;
const method_handler: ROUTE_HANDLER_METHOD = (handler_module[method] ?? handler_module.default) as ROUTE_HANDLER_METHOD;