All files / proxy/utils cookie.ts

100% Statements 12/12
100% Branches 2/2
100% Functions 2/2
100% Lines 12/12

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 198x 20x 20x   20x 26x 26x 26x 13x 13x 13x 7x         20x    
export function filterCookie(cookie: string, filterPredicate: (key: string) => boolean): string {
  const newCookie: string[] = []
  const parts = cookie.split(';')
 
  parts.forEach((it) => {
    const s = it.trim()
    const ind = s.indexOf('=')
    if (ind !== -1) {
      const key = s.substring(0, ind)
      const value = s.substring(ind + 1)
      if (filterPredicate(key)) {
        newCookie.push(`${key}=${value}`)
      }
    }
  })
 
  return newCookie.join('; ').trim()
}