From 4f6f86980073319851c0624b9f2cf3f5f646b23c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Andr=C3=A9?= Date: Mon, 6 Jan 2025 00:11:26 +0100 Subject: [PATCH] Reuse 'Content-Disposition' header value Co-authored-by: Hugo Alliaume --- src/LiveComponent/assets/src/Component/index.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/LiveComponent/assets/src/Component/index.ts b/src/LiveComponent/assets/src/Component/index.ts index b53aa0b57d..502e343623 100644 --- a/src/LiveComponent/assets/src/Component/index.ts +++ b/src/LiveComponent/assets/src/Component/index.ts @@ -308,12 +308,11 @@ export default class Component { const headers = backendResponse.response.headers; if (headers.get('X-Live-Download')) { + const headerContentDisposition = headers.get('Content-Disposition'); if ( - !( - headers.get('Content-Disposition')?.includes('attachment') || - headers.get('Content-Disposition')?.includes('inline') - ) || - !headers.get('Content-Disposition')?.includes('filename=') + !headerContentDisposition + || !(headerContentDisposition?.includes('attachment') || headerContentDisposition?.includes('inline')) + || !headerContentDisposition?.includes('filename=') ) { throw new Error('Invalid LiveDownload response'); }