DEV: Fix "no-empty" lint (#24588)

This commit is contained in:
Jarek Radosz 2023-11-28 10:55:02 +01:00 committed by GitHub
parent 70dc6bcfd3
commit e9356c2ec9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 6 deletions

View File

@ -6,14 +6,17 @@ function insertSpoiler(_, spoiler) {
}
function replaceSpoilers(text) {
text = text || "";
while (
text !==
(text = text.replace(
text ||= "";
let previousText;
do {
previousText = text;
text = text.replace(
/\[spoiler\]((?:(?!\[spoiler\]|\[\/spoiler\])[\S\s])*)\[\/spoiler\]/gi,
insertSpoiler
))
) {}
);
} while (text !== previousText);
return text;
}