From ba13007dce63d211eb6a168f502f58af01a6ca1f Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Wed, 28 Feb 2024 11:30:33 -0300 Subject: src/utils.mjs: Define strSortFn() and use it on all files --- src/hero.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/hero.mjs') diff --git a/src/hero.mjs b/src/hero.mjs index 268136f..c249d4f 100644 --- a/src/hero.mjs +++ b/src/hero.mjs @@ -31,7 +31,7 @@ const HTTP_METHODS = new Set([ "OPTIONS", ]); -const HTTP_METHODS_ARR = [...HTTP_METHODS.keys()].sort(); +const HTTP_METHODS_ARR = [...HTTP_METHODS.keys()].sort(u.strSortFn); export const addRoute = (table, methods, path, handlerFn) => { if (methods === "*") { @@ -88,7 +88,7 @@ export const firstParamMatch = (tree, segments, params) => { // literal matching failed, we now look for patterns that might match const paramOptions = Object.keys(tree) .filter(s => s.startsWith(":")) - .sort(); + .sort(u.strSortFn); return u.first(paramOptions, param => firstParamMatch(tree[param], nextSegments, { ...params, [param.slice(1)]: seg -- cgit v1.2.3