From 513f1345caf457d80a0e249e5815cf7cb156f8c7 Mon Sep 17 00:00:00 2001 From: Codex Date: Sun, 7 Jun 2026 17:03:24 +0800 Subject: [PATCH] fix admin axios header typecheck --- admin/app/services/map_service.ts | 2 +- admin/app/utils/downloads.ts | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/admin/app/services/map_service.ts b/admin/app/services/map_service.ts index c1157b0..0bafcf2 100644 --- a/admin/app/services/map_service.ts +++ b/admin/app/services/map_service.ts @@ -300,7 +300,7 @@ export class MapService implements IMapService { throw new Error(`Failed to fetch file info: ${response.status} ${response.statusText}`) } - const contentLength = response.headers['content-length'] + const contentLength = String(response.headers['content-length'] ?? '') const size = contentLength ? parseInt(contentLength, 10) : 0 return { filename, size } diff --git a/admin/app/utils/downloads.ts b/admin/app/utils/downloads.ts index 23988da..bb76cd5 100644 --- a/admin/app/utils/downloads.ts +++ b/admin/app/utils/downloads.ts @@ -53,9 +53,8 @@ export async function doResumableDownload({ // already in every binary-content allowlist we use (ZIM, PMTILES, base assets). // Without this default, the validator below throws `MIME type is not allowed` // and breaks all downloads from kiwix's primary host (#848). - const contentType = - headResponse.headers['content-type'] || 'application/octet-stream' - const totalBytes = parseInt(headResponse.headers['content-length'] || '0') + const contentType = String(headResponse.headers['content-type'] ?? 'application/octet-stream') + const totalBytes = parseInt(String(headResponse.headers['content-length'] ?? '0')) const supportsRangeRequests = headResponse.headers['accept-ranges'] === 'bytes' // If allowedMimeTypes is provided, check content type