All files / app/codeCharta/ui/ribbonBar/searchPanel/searchBar/utils parseBlacklistItems.ts

94.11% Statements 16/17
80% Branches 4/5
100% Functions 1/1
93.75% Lines 15/16

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 14 15 16 17 18 19 20 21 22 23 24 25 26 27  6x   6x 5x 5x 5x 1x 1x 2x 2x       4x 5x 5x     5x 5x       5x    
import { BlacklistItem, BlacklistType } from "../../../../../codeCharta.model"
import { unifyWildCard } from "./unifyWildCard"
 
export const parseBlacklistItems = (blacklistType: BlacklistType, searchPattern: string) => {
    const blacklistItems: BlacklistItem[] = []
    const paths: string[] = searchPattern.split(",")
    if (paths[0].startsWith("!")) {
        paths[0] = paths[0].slice(1)
        for (const path of paths) {
            if (path.length > 0) {
                blacklistItems.push({ path: `!${unifyWildCard(path)}`, type: blacklistType })
            }
        }
    } else {
        for (let path of paths) {
            if (path.length > 0) {
                Iif (path.startsWith("!")) {
                    break
                }
                path = unifyWildCard(path)
                blacklistItems.push({ path, type: blacklistType })
            }
        }
    }
    return blacklistItems
}