modules.move: fix !move ignoring the last letter of the category name

master
Miikka 2018-04-25 02:21:24 +03:00 committed by GitHub
parent f13f2eee2d
commit d6793d5c12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 7 deletions

View File

@ -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];
});