Skip to content

Commit

Permalink
fix(titles): more robust handling of title generation for untitled sc…
Browse files Browse the repository at this point in the history
…hemas

see #185
  • Loading branch information
trieloff committed Dec 18, 2019
1 parent d0580fd commit c546a28
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/formattingTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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}`;
}

Expand Down

0 comments on commit c546a28

Please sign in to comment.