discourse/app/assets/javascripts/discourse-common/addon/utils/watched-words.js

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 };
}