1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 07:27:25 +08:00

Using static call and verbatim symbol and optimizes regex pattern for username check

This commit is contained in:
tbrose 2021-12-07 02:38:10 +01:00
parent be86ca582c
commit 882223b27f

View File

@ -134,7 +134,7 @@ namespace osu.Game.Online.Chat
{
string fullName = Regex.Escape(username);
string underscoreName = Regex.Escape(username.Replace(' ', '_'));
return new Regex($"(^|^\\W|\\W|\\w\\W)({fullName}|{underscoreName})($|$\\W|\\W|\\w\\W)", RegexOptions.IgnoreCase).IsMatch(message);
return Regex.IsMatch(message, $@"(^|\W)({fullName}|{underscoreName})($|\W)", RegexOptions.IgnoreCase);
}
public class PrivateMessageNotification : OpenChannelNotification