Skip to content

Project NOMAD is an offline-first knowledge and education server. Wikipedia, thousands of books, courses, maps, and optional local AI, all running on hardware you own with no internet required.

TypeScript

fix: minor type guarding fixes after axios bump

jakeaturnerb2bea191a85b
diff --git a/admin/app/services/map_service.ts b/admin/app/services/map_service.ts
index c1157b0e..0e1c9025 100644
--- a/admin/app/services/map_service.ts
+++ b/admin/app/services/map_service.ts
@@ -301,7 +301,7 @@ export class MapService implements IMapService {
}
const contentLength = response.headers['content-length']
- const size = contentLength ? parseInt(contentLength, 10) : 0
+ const size = contentLength ? parseInt(contentLength.toString(), 10) : 0
return { filename, size }
} catch (error: any) {
diff --git a/admin/app/utils/downloads.ts b/admin/app/utils/downloads.ts
index 23988da0..bfe189a1 100644
--- a/admin/app/utils/downloads.ts
+++ b/admin/app/utils/downloads.ts
@@ -54,8 +54,8 @@ export async function doResumableDownload({
// 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')
+ headResponse.headers['content-type']?.toString() || 'application/octet-stream'
+ const totalBytes = parseInt(headResponse.headers['content-length']?.toString() || '0', 10)
const supportsRangeRequests = headResponse.headers['accept-ranges'] === 'bytes'
// If allowedMimeTypes is provided, check content type