Disable dinkus extension if no separator is set.

This commit is contained in:
Cohee
2023-06-11 14:30:32 +03:00
parent 525b9dc0bb
commit 3829580aab

View File

@ -9,6 +9,12 @@ export const dinkusExtension = () => {
// Create an escaped sequence so the regex can work with any character
const savedDinkus = power_user.custom_chat_separator
// No dinkus? No extension!
if (!savedDinkus || savedDinkus.trim().length === 0) {
return []
}
const escapedDinkus = savedDinkus.split('').map((e) => `\\${e}`).join('');
const replaceRegex = new RegExp(`^(${escapedDinkus})\n`, "gm")
return [{
@ -16,4 +22,4 @@ export const dinkusExtension = () => {
regex: replaceRegex,
replace: (match) => match.replace(replaceRegex, `<div>${savedDinkus}</div>`).trim()
}];
}
}