mirror of
https://github.com/discourse/discourse.git
synced 2024-12-03 00:43:40 +08:00
9a2780397f
Watched words were converted to regular expressions containing \W, which handled only ASCII characters. Using [^[:word]] instead ensures that UTF-8 characters are also handled correctly.
10 lines
302 B
JavaScript
10 lines
302 B
JavaScript
export function createWatchedWordRegExp(word) {
|
|
const caseFlag = word.case_sensitive ? "" : "i";
|
|
return new RegExp(word.regexp, `${caseFlag}gu`);
|
|
}
|
|
|
|
export function toWatchedWord(regexp) {
|
|
const [[regexpString, options]] = Object.entries(regexp);
|
|
return { regexp: regexpString, ...options };
|
|
}
|