1
0
mirror of https://github.com/sasjs/server.git synced 2026-01-08 23:10:05 +00:00

fix: return buffer in case of file response

This commit is contained in:
Saad Jutt
2022-02-20 05:40:03 +05:00
parent 0a4b202428
commit 3e6234e601
6 changed files with 59 additions and 25 deletions

View File

@@ -4,14 +4,14 @@ export interface HTTPHeaders {
[key: string]: string
}
export const extractHeaders = (content: string): HTTPHeaders => {
export const extractHeaders = (content?: string): HTTPHeaders => {
const headersObj: HTTPHeaders = {}
const headersArr = content
.split('\n')
?.split('\n')
.map((line) => line.trim())
.filter((line) => !!line)
headersArr.forEach((headerStr) => {
headersArr?.forEach((headerStr) => {
const [key, value] = headerStr.split(':').map((data) => data.trim())
if (value && headerUtils.validateHeader(key, value)) {