1
0
Fork 0
mirror of synced 2024-09-21 03:43:21 +12:00

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 filename: string | undefined
const contentType = response.headers.get("content-type") || "" const contentType = response.headers.get("content-type") || ""
const contentDisposition = response.headers.get("content-disposition") || "" let contentDisposition = response.headers.get("content-disposition") || ""
if ( if (
contentDisposition.includes("filename") || contentDisposition.includes("filename") ||
contentDisposition.includes("attachment") || contentDisposition.includes("attachment") ||
contentDisposition.includes("form-data") 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 = filename =
path.basename(parse(contentDisposition).parameters?.filename) || "" path.basename(parse(contentDisposition).parameters?.filename) || ""
} }

645
yarn.lock

File diff suppressed because it is too large Load diff