Typescript parse content-disposition header

Date: 2022-11-07
const contentDispositionRegex = /filename=["']?([^"']+?)["']/gmi;
export function getFileNameFromContentDispositionHeader(headerValue: string) {
    const match = Array.from(String(headerValue).matchAll(contentDispositionRegex))[0];
    return match ? decodeURIComponent(match[1]) : "file.dat";
}
69510cookie-checkTypescript parse content-disposition header