From 82a89b6e86652480793bc4c3a16b5a9295204d33 Mon Sep 17 00:00:00 2001 From: Miikka Date: Wed, 25 Apr 2018 02:25:49 +0300 Subject: [PATCH] modules.move: slightly prioritize categories that start with the search string --- src/modules/move.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/move.js b/src/modules/move.js index 818a31e..5be351f 100644 --- a/src/modules/move.js +++ b/src/modules/move.js @@ -32,6 +32,11 @@ module.exports = bot => { if (! normalizedCatName.includes(normalizedSearchStr.slice(0, i + 1))) break; i++; } while (i < normalizedSearchStr.length); + + if (i > 0 && normalizedCatName.startsWith(normalizedSearchStr.slice(0, i))) { + // Slightly prioritize categories that *start* with the search string + i += 0.5; + } return [cat, i]; });