parent
5c400a2842
commit
c6942a5283
5 changed files with 52 additions and 3 deletions
@ -0,0 +1,19 @@ |
|||||||
|
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')); |
||||||
|
} |
Loading…
Reference in new issue