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 | 12x 12x 34x 34x 34x 34x 9x 3x 34x 34x 3x 34x | import { parse } from 'cookie'
export function filterCookies(headers: Headers, filterFunc: (key: string) => boolean): Headers {
const newHeaders = new Headers(headers)
const cookie = parse(headers.get('cookie') || '')
const filteredCookieList = []
for (const cookieName in cookie) {
if (filterFunc(cookieName)) {
filteredCookieList.push(`${cookieName}=${cookie[cookieName]}`)
}
}
newHeaders.delete('cookie')
if (filteredCookieList.length > 0) {
newHeaders.set('cookie', filteredCookieList.join('; '))
}
return newHeaders
}
|