gaoxiaoliangz/epub-parser

errorMessage": "Cannot read property 'href' of undefined (toc attribute not found in spine?)

ysa000 opened this issue · 2 comments

Hello @gaoxiaoliangz,

I have encountered the following error while parsing an ePub:

errorMessage": "Cannot read property 'href' of undefined", "errorType": "TypeError", "stackTrace": [ "TypeError: Cannot read property 'href' of undefined", " at Epub.<anonymous> (/Users/xx/Desktop/workspaces/xxx/node_modules/@gxl/epub-parser/src/parseEpub.ts:185:52)",

I think that the above issue might be because of the toc attribute not being found in the <spine /> tag. I've tried removing the unused attribute in the .opf file, and replaced it with the expected toc attribute, and I did not have the error anymore.

The ePub 3.2 specifications points out the toc attribute is optional in the <spine />. Instead of breaking, shouldn't it advisable to continue the parsing process when the attribute is not found ?

Thanks in advance @gaoxiaoliangz for your reply and keep up the good work 😊

Thanks for the feedback, I'll be woking on it when I have time.

The new version(v2.0.2) is now released, this should have been fixed.