From d2e1c113ecd12f355447c3340927920df06e457b Mon Sep 17 00:00:00 2001 From: Xavier Jp Date: Fri, 11 Oct 2024 11:33:27 +0200 Subject: [PATCH] fix: la poste pdf incorrectly cast as 404 (#1265) * fix: la poste pdf incorrectly cast as 404 * Update hooks/fetch/download-pdf.ts Co-authored-by: Robin Monnier Signed-off-by: Xavier Jp --------- Signed-off-by: Xavier Jp Co-authored-by: Robin Monnier --- hooks/fetch/download-pdf.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hooks/fetch/download-pdf.ts b/hooks/fetch/download-pdf.ts index df8e7bad5..788b37888 100644 --- a/hooks/fetch/download-pdf.ts +++ b/hooks/fetch/download-pdf.ts @@ -5,7 +5,7 @@ import { httpGet } from '#utils/network'; import logErrorInSentry from '#utils/sentry'; import { useFetchExternalData } from './use-fetch-data'; -const is404 = (msg: string) => msg.indexOf('Siren non existant') !== 0; +const isPdfNotFound = (msg: string) => msg.indexOf('Siren non existant') === 0; export function usePDFDownloader(pdfLink: string) { return useFetchExternalData( @@ -14,7 +14,7 @@ export function usePDFDownloader(pdfLink: string) { try { return await httpGet(pdfLink, { responseType: 'blob' }); } catch (e: any) { - if (is404(e?.message)) { + if (isPdfNotFound(e?.message)) { throw new HttpNotFound('Not found - 404'); } throw e;