Skip to content

Commit

Permalink
fix: use findMimeTypeWithExtension helper to handle lower/upper case
Browse files Browse the repository at this point in the history
file extension
  • Loading branch information
panaC committed Nov 27, 2024
1 parent 2582549 commit 8bd1c77
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/streamer/streamerNoHttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import {
} from "./streamerCommon";
import { OPDS_MEDIA_SCHEME } from "readium-desktop/main/redux/sagas/getEventChannel";
import { THORIUM_READIUM2_ELECTRON_HTTP_PROTOCOL } from "readium-desktop/common/streamerProtocol";
import { mimeTypes } from "readium-desktop/utils/mimeTypes";
import { findMimeTypeWithExtension } from "readium-desktop/utils/mimeTypes";

// import { _USE_HTTP_STREAMER } from "readium-desktop/preprocessor-directives";

Expand Down Expand Up @@ -287,11 +287,12 @@ const streamProtocolHandler = async (
folderPath = path.join(process.cwd(), "dist", pdfjsFolder);
}
const pdfjsFullPathname = path.normalize(`${folderPath}/${pdfjsUrlPathname}`);
const fileExtension = path.extname(pdfjsFullPathname);
debug("PDFJS full path name :", pdfjsFullPathname);

const contentLength = `${fs.statSync(pdfjsFullPathname)?.size || 0}`;
headers["Content-Length"] = contentLength;
const contentType = `${mimeTypes[path.extname(pdfjsFullPathname).slice(1) as keyof typeof mimeTypes] || ""}; charset=utf-8`;
const contentType = `${findMimeTypeWithExtension(fileExtension) || ""}; charset=utf-8`;
headers["Content-Type"] = contentType;
debug("PDFJS content-type:", contentType, contentLength);
const obj = {
Expand Down

0 comments on commit 8bd1c77

Please sign in to comment.