All files / plugins strip_tags.js

28.57% Statements 2/7
0% Branches 0/3
0% Functions 0/3
33.33% Lines 2/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13      1x   1x              
import {toStr} from "../helpers/string/to_string";
import { REGEXP_TAGS } from "../helpers/regexp/regexp";
 
export const stripTagsAll = s => toStr(s).replace(REGEXP_TAGS, '')
 
export const stripTags = (s, allowed = []) => {
    let _s = toStr(s)
    let tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>/gi
 
    return _s.replace(tags, ($0, $1) => {
        return allowed.includes($1) ? $0 : ''
    })
}