From 8b6a80cffbb991db70687cf226bcf71f6a7740d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Tue, 24 Jun 2014 12:34:29 +0200 Subject: [PATCH] Fix error when chapters list is empty Fix GitbookIO/gitbook.io#101 and GitbookIO/gitbook.io#102 --- lib/parse/summary.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/parse/summary.js b/lib/parse/summary.js index 7746f109b..fd300bc9e 100644 --- a/lib/parse/summary.js +++ b/lib/parse/summary.js @@ -100,11 +100,13 @@ function parseChapter(nodes, nums) { function defaultChapterList(chapterList) { var first = _.first(chapterList); - var chapter = parseChapter(first, [0]); + if (first) { + var chapter = parseChapter(first, [0]); - // Already have README node, we're good to go - if(chapter.path === 'README.md') { - return chapterList; + // Already have README node, we're good to go + if(chapter.path === 'README.md') { + return chapterList; + } } return [