From c546a28d4392634c8ab87725628281e568635b95 Mon Sep 17 00:00:00 2001 From: Lars Trieloff Date: Wed, 18 Dec 2019 08:47:24 +0000 Subject: [PATCH] fix(titles): more robust handling of title generation for untitled schemas see #185 --- lib/formattingTools.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/formattingTools.js b/lib/formattingTools.js index 8118d5b4..d4550f8f 100644 --- a/lib/formattingTools.js +++ b/lib/formattingTools.js @@ -15,7 +15,8 @@ const s = require('./symbols'); function gentitle(titles, type) { const [firsttitle] = titles; const lasttitle = [...titles].pop(); - if (titles.length === 1) { + + if (titles.length === 1 && firsttitle !== undefined) { return firsttitle; } if (lasttitle) { @@ -24,6 +25,9 @@ function gentitle(titles, type) { if (typeof type === 'string') { return i18n`Untitled ${type} in ${firsttitle}`; } + if (firsttitle === undefined) { + return i18n`Untitled Schema`; + } return i18n`Untitled undefined type in ${firsttitle}`; }