mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-24 12:48:07 +01:00
c6942a5283
Fixes #678
19 lines
460 B
JavaScript
19 lines
460 B
JavaScript
export function autoUnfoldCW (settings, status) {
|
|
if (!settings.getIn(['content_warnings', 'auto_unfold'])) {
|
|
return false;
|
|
}
|
|
|
|
const rawRegex = settings.getIn(['content_warnings', 'filter']);
|
|
let regex = null;
|
|
|
|
try {
|
|
regex = rawRegex && new RegExp(rawRegex.trim(), 'i');
|
|
} catch (e) {
|
|
// Bad regex, don't affect filters
|
|
}
|
|
|
|
if (!(status && regex)) {
|
|
return undefined;
|
|
}
|
|
return !regex.test(status.get('spoiler_text'));
|
|
}
|