mirror of
https://github.com/sasjs/server.git
synced 2026-04-09 15:13:13 +00:00
fix: return buffer in case of file response
This commit is contained in:
@@ -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)) {
|
||||
|
||||
@@ -37,4 +37,16 @@ describe('extractHeaders', () => {
|
||||
|
||||
expect(headers).toEqual({})
|
||||
})
|
||||
|
||||
it('should return http headers if empty', () => {
|
||||
const headers = extractHeaders('')
|
||||
|
||||
expect(headers).toEqual({})
|
||||
})
|
||||
|
||||
it('should return http headers if not provided', () => {
|
||||
const headers = extractHeaders()
|
||||
|
||||
expect(headers).toEqual({})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user