Skip to content

Commit

Permalink
Fix crash on empty chapters
Browse files Browse the repository at this point in the history
  • Loading branch information
christianroy authored and julien-c committed Oct 22, 2018
1 parent 4fc7b77 commit 124d461
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion epub.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ class EPub extends EventEmitter {

var title = '';
if (branch[i].navLabel && typeof branch[i].navLabel.text == 'string') {
title = branch[i].navLabel && branch[i].navLabel.text || branch[i].navLabel===branch[i].navLabel ?
title = branch[i].navLabel && branch[i].navLabel.text || branch[i].navLabel===branch[i].navLabel && branch[i].navLabel.text.length > 0 ?
(branch[i].navLabel && branch[i].navLabel.text || branch[i].navLabel || "").trim() : '';
}
var order = Number(branch[i]["@"] && branch[i]["@"].playOrder || 0);
Expand Down
7 changes: 7 additions & 0 deletions test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,11 @@ mocha.describe('EPub', () => {
`/images/`
);
});

mocha.it('supports empty chapters', () => {
var branch = [{navLabel: { text: '' }}];
const epub = new EPub();
var res = epub.walkNavMap(branch, [], []);
assert.ok(res);
});
});

0 comments on commit 124d461

Please sign in to comment.