summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/accretion.mjs3
-rw-r--r--src/hero.mjs4
-rw-r--r--src/utils.mjs2
3 files changed, 5 insertions, 4 deletions
diff --git a/src/accretion.mjs b/src/accretion.mjs
index 1c70162..dd3372c 100644
--- a/src/accretion.mjs
+++ b/src/accretion.mjs
@@ -26,8 +26,7 @@ export const runMigrations = async (logFn, db) => {
.map(row => row.filename);
const allFiles = fs.readdirSync(MIGRATIONS_DIR, "UTF-8");
const pending = u.difference(new Set(allFiles), new Set(done));
- const sortedPending = [...pending]
- .sort((a, b) => a.localeCompare(b, "POSIX"));
+ const sortedPending = [...pending].sort(u.strSortFn);
for (const filename of sortedPending) {
logFn({ log: "exec-migration", filename });
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
diff --git a/src/utils.mjs b/src/utils.mjs
index c671f0f..cde6934 100644
--- a/src/utils.mjs
+++ b/src/utils.mjs
@@ -80,3 +80,5 @@ export const promisify = fn => (...args) =>
export const partial = (fn, ...startArgs) =>
(...endArgs) =>
fn(...startArgs, ...endArgs);
+
+export const strSortFn = (a, b) => a.localeCompare(b, "POSIX");