From d593d3f0e27c9206b4de4197af9057ec2f465829 Mon Sep 17 00:00:00 2001 From: kevin Date: Thu, 19 Mar 2026 10:24:41 +0100 Subject: [PATCH] fix: status app --- composables/useApiAuth.ts | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/composables/useApiAuth.ts b/composables/useApiAuth.ts index de6f734..749bfa9 100644 --- a/composables/useApiAuth.ts +++ b/composables/useApiAuth.ts @@ -1,20 +1,3 @@ -function getDownloadFileName(contentDisposition: string | null, fallback: string) { - if (!contentDisposition) { - return fallback - } - - const utf8Match = contentDisposition.match(/filename\*=UTF-8''([^;]+)/i) - if (utf8Match?.[1]) { - return decodeURIComponent(utf8Match[1]) - } - - const asciiMatch = contentDisposition.match(/filename="([^"]+)"/i) - if (asciiMatch?.[1]) { - return asciiMatch[1] - } - - return fallback -} export const apiFetch = $fetch.create({}) export function apiRequest(input: RequestInfo | URL, init: RequestInit = {}) { @@ -22,29 +5,14 @@ export function apiRequest(input: RequestInfo | URL, init: RequestInit = {}) { } export async function downloadApiFile(url: string, fileNameFallback: string) { - // Les telechargements passent aussi par fetch pour pouvoir recuperer - // le contenu et le nom de fichier renvoye par l'API. - const response = await apiRequest(url) - - if (!response.ok) { - throw new Error(`HTTP ${response.status}`) - } - - const blob = await response.blob() - const objectUrl = URL.createObjectURL(blob) - const fileName = getDownloadFileName( - response.headers.get("content-disposition"), - fileNameFallback - ) const link = document.createElement("a") - link.href = objectUrl - link.download = fileName + link.href = url + link.download = fileNameFallback link.style.display = "none" document.body.appendChild(link) link.click() link.remove() - URL.revokeObjectURL(objectUrl) } export function withApiAuth(init: RequestInit = {}) {