From 57f7b1c0118d2cd02fda547451f8ab489b6a921f Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 7 Mar 2024 11:40:37 +0100 Subject: [PATCH] lib/irc: fix whitespace split in isURIPrefix We want to get the last index of whitespace, not the first one. --- lib/irc.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/irc.js b/lib/irc.js index 991c47d..d6d90c4 100644 --- a/lib/irc.js +++ b/lib/irc.js @@ -278,9 +278,11 @@ function isWordBoundary(ch) { } function isURIPrefix(text) { - let i = text.search(space); - if (i >= 0) { - text = text.slice(i); + for (let i = text.length - 1; i >= 0; i--) { + if (text[i].search(space)) { + text = text.slice(i); + break; + } } i = text.indexOf("://");