From d6793d5c124433d4858e12fce25845798032bbd1 Mon Sep 17 00:00:00 2001 From: Miikka Date: Wed, 25 Apr 2018 02:21:24 +0300 Subject: [PATCH] modules.move: fix !move ignoring the last letter of the category name --- src/modules/move.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/modules/move.js b/src/modules/move.js index 2dbdca9..818a31e 100644 --- a/src/modules/move.js +++ b/src/modules/move.js @@ -27,13 +27,11 @@ module.exports = bot => { const containsRankings = categories.map(cat => { const normalizedCatName = transliterate.slugify(cat.name); - let i; - for (i = 1; i < normalizedSearchStr.length; i++) { - if (! normalizedCatName.includes(normalizedSearchStr.slice(0, i))) { - i--; - break; - } - } + let i = 0; + do { + if (! normalizedCatName.includes(normalizedSearchStr.slice(0, i + 1))) break; + i++; + } while (i < normalizedSearchStr.length); return [cat, i]; });