Fixed bug where including search command in your search text caused a malformed search. Also fixed a bug where the result index error notice wasn't being formed properly.

This commit is contained in:
q 2023-01-22 14:25:28 -05:00
parent 10651f2863
commit 26fa6cbd0b

View File

@ -164,7 +164,7 @@ Searx.prototype.handleMessage = function(event, room) {
} }
else { else {
if (isNaN(messagePieces[1])) { if (isNaN(messagePieces[1])) {
toSearch = event.getContent().body.substr(event.getContent().body.indexOf(messagePieces[1])); toSearch = event.getContent().body.substr(messagePieces[0].length+1);
} }
else { else {
resultIndex = Number(messagePieces[1]) - 1; resultIndex = Number(messagePieces[1]) - 1;
@ -174,7 +174,7 @@ Searx.prototype.handleMessage = function(event, room) {
return; return;
} }
toSearch = event.getContent().body.substr(event.getContent().body.indexOf(messagePieces[2])); toSearch = event.getContent().body.substr(messagePieces[0].length+messagePieces[1].length+2);
} }
} }
@ -194,7 +194,8 @@ Searx.prototype.handleMessage = function(event, room) {
return; return;
} }
else if (resultIndex > (results.length - 1)) { else if (resultIndex > (results.length - 1)) {
matrixClient.sendNotice(room.roomId, "No result found for \""+toSearch+"\" at position "+resultIndex+1); const noticeIndex = resultIndex+1;
matrixClient.sendNotice(room.roomId, "No result found for \""+toSearch+"\" at position "+noticeIndex);
return; return;
} }