mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-06-03 06:18:12 -05:00
Don't throw from getHighlight
This commit is contained in:
parent
63f62b3991
commit
54c80f0247
10
js/sim.js
10
js/sim.js
|
|
@ -1307,7 +1307,15 @@ function Lobby(id, elem) {
|
|||
this.getHighlight = function (message) {
|
||||
var highlights = Tools.prefs.get('highlights') || [];
|
||||
if (!this.regex) {
|
||||
this.regex = new RegExp('\\b('+highlights.join('|')+')\\b', 'gi');
|
||||
try {
|
||||
this.regex = new RegExp('\\b('+highlights.join('|')+')\\b', 'gi');
|
||||
} catch (e) {
|
||||
// If the expression above is not a regexp, we'll get here.
|
||||
// Don't throw an exception because that would prevent the chat
|
||||
// message from showing up, or, when the lobby is initialising,
|
||||
// it will prevent the initialisation from completing.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return ((highlights.length > 0) && this.regex.test(message));
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user