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:
parent
7e1eddc787
commit
16f6cad1ea
|
@ -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) || ""
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue