fix: Rename duplicate extractFB2Metadata in fb2-parser
Fix infinite recursion bug where exported function called itself. Renamed to getFB2Metadata to avoid duplicate declaration.
This commit is contained in:
@@ -222,14 +222,19 @@ function generatePageBreaks(totalCharacters: number): number[] {
|
|||||||
// Metadata Quick Extract
|
// Metadata Quick Extract
|
||||||
// ============================================================
|
// ============================================================
|
||||||
|
|
||||||
export async function extractFB2Metadata(
|
export async function getFB2Metadata(
|
||||||
fb2Blob: Blob,
|
fb2Blob: Blob,
|
||||||
): Promise<Partial<EbookCIF["metadata"]>> {
|
): Promise<Partial<EbookCIF["metadata"]>> {
|
||||||
let xmlContent: string;
|
let xmlContent: string;
|
||||||
|
|
||||||
if (fb2Blob.type === "application/zip") {
|
if (
|
||||||
|
fb2Blob.type === "application/zip" ||
|
||||||
|
fb2Blob.type === "application/x-zip-compressed"
|
||||||
|
) {
|
||||||
const zip = await JSZip.loadAsync(fb2Blob);
|
const zip = await JSZip.loadAsync(fb2Blob);
|
||||||
const files = Object.keys(zip.files);
|
const files = Object.keys(zip.files);
|
||||||
|
|
||||||
|
// Find the first .fb2 file in the zip
|
||||||
const fb2File = files.find((f) => f.endsWith(".fb2"));
|
const fb2File = files.find((f) => f.endsWith(".fb2"));
|
||||||
|
|
||||||
if (!fb2File) return {};
|
if (!fb2File) return {};
|
||||||
|
|||||||
Reference in New Issue
Block a user