Properly handle empty fragments for MOBI (#107)

This commit is contained in:
Huang Xin
2025-11-28 22:39:57 +00:00
committed by GitHub
parent c49ded0cc4
commit 6b11e17443
+1 -1
View File
@@ -994,7 +994,7 @@ class KF8 {
const last = arr[arr.length - 1] const last = arr[arr.length - 1]
const fragStart = last?.fragEnd ?? 0, fragEnd = fragStart + skel.numFrag const fragStart = last?.fragEnd ?? 0, fragEnd = fragStart + skel.numFrag
const frags = fragTable.slice(fragStart, fragEnd) const frags = fragTable.slice(fragStart, fragEnd)
const length = skel.length + frags.map(f => f.length).reduce((a, b) => a + b) const length = skel.length + frags.map(f => f.length).reduce((a, b) => a + b, 0)
const totalLength = (last?.totalLength ?? 0) + length const totalLength = (last?.totalLength ?? 0) + length
return arr.concat({ skel, frags, fragEnd, length, totalLength }) return arr.concat({ skel, frags, fragEnd, length, totalLength })
}, []) }, [])