Merge pull request #2169 from Wolfsblvt/fix-wi-whole-world

Fixes WI word matching not working for non-words
This commit is contained in:
Cohee 2024-05-01 11:07:31 +03:00 committed by GitHub
commit 51f0d1f33e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -192,7 +192,8 @@ class WorldInfoBuffer {
return haystack.includes(transformedString);
}
else {
const regex = new RegExp(`\\b${escapeRegex(transformedString)}\\b`);
// Use custom boundaries to include punctuation and other non-alphanumeric characters
const regex = new RegExp(`(?:^|\\W)(${escapeRegex(transformedString)})(?:$|\\W)`);
if (regex.test(haystack)) {
return true;
}