fix admin axios header typecheck

This commit is contained in:
Codex 2026-06-07 17:03:24 +08:00
parent 97e17b8664
commit 513f1345ca
2 changed files with 3 additions and 4 deletions

View File

@ -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 }

View File

@ -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