julien-c / epub

node.js epub reader
https://www.npmjs.com/package/epub
Other
333 stars 307 forks source link

Fix crash on empty chapters #40

Closed christianroy closed 5 years ago

christianroy commented 5 years ago

Previously the parser would crash with the following error:

TypeError: (((branch[i].navLabel && branch[i].navLabel.text) || branch[i].navLabel) || "").trim is not a function
      at EPub.walkNavMap (epub.js:562:102)

when navLabel.text is an empty string, on line 562. I fixed it and added a simple test to show it works (you can remove the fix in epub.js and see the test crash).

julien-c commented 5 years ago

Thanks!