Adding a hack incase any API we are speaking to does not abide by the expected structure of the content-disposition header, fill in the missing type to allow parsing.

This commit is contained in:
mike12345567 2024-05-15 13:28:03 +01:00
parent 7e1eddc787
commit 16f6cad1ea
2 changed files with 151 additions and 502 deletions

View File

@ -137,12 +137,18 @@ class RestIntegration implements IntegrationBase {
filename: string | undefined
const contentType = response.headers.get("content-type") || ""
const contentDisposition = response.headers.get("content-disposition") || ""
let contentDisposition = response.headers.get("content-disposition") || ""
if (
contentDisposition.includes("filename") ||
contentDisposition.includes("attachment") ||
contentDisposition.includes("form-data")
) {
// the API does not follow the requirements of https://www.ietf.org/rfc/rfc2183.txt
// all content-disposition headers should be format disposition-type; parameters
// but some APIs do not provide a type, causing the parse below to fail - add one to fix this
if (!contentDisposition.includes(";")) {
contentDisposition = `attachment; ${contentDisposition}`
}
filename =
path.basename(parse(contentDisposition).parameters?.filename) || ""
}

645
yarn.lock

File diff suppressed because it is too large Load Diff