From abec73689c490d147d7874d9cf593af901f49b5c Mon Sep 17 00:00:00 2001 From: Lars Trieloff Date: Thu, 8 Jul 2021 10:06:48 +0200 Subject: [PATCH] fix(i18n): avoid passing non-string parameters to i18n engine --- lib/formattingTools.js | 2 +- lib/markdownBuilder.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/formattingTools.js b/lib/formattingTools.js index 05f315a1..4806f58b 100644 --- a/lib/formattingTools.js +++ b/lib/formattingTools.js @@ -26,7 +26,7 @@ function gentitle(titles, type) { return lasttitle; } if (typeof type === 'string') { - return i18n`Untitled ${type} in ${firsttitle}`; + return i18n`Untitled ${type} in ${String(firsttitle)}`; } if (firsttitle === undefined) { return i18n`Untitled schema`; diff --git a/lib/markdownBuilder.js b/lib/markdownBuilder.js index 0c2a92fd..a8bde8c8 100644 --- a/lib/markdownBuilder.js +++ b/lib/markdownBuilder.js @@ -645,12 +645,12 @@ function build({ } if (schema[keyword`minContains`] !== undefined && schema[keyword`contains`]) { // console.log('minContains!', schema[s.filename], schema[s.pointer]); - constraints.push(paragraph([strong(text(i18n`minimum number of contained items`)), text(': '), text(`${i18n`this array may not contain fewer than ${schema[keyword`minContains`]} items that validate against the schema:`} `), + constraints.push(paragraph([strong(text(i18n`minimum number of contained items`)), text(': '), text(`${i18n`this array may not contain fewer than ${String(schema[keyword`minContains`])} items that validate against the schema:`} `), link(`${schema[keyword`contains`][s.slug]}.md`, i18n`check type definition`, text(gentitle(schema[keyword`contains`][s.titles], schema[keyword`contains`][keyword`type`])))])); } if (schema[keyword`maxContains`] !== undefined && schema[keyword`contains`]) { // console.log('maxContains!', schema[s.filename], schema[s.pointer]); - constraints.push(paragraph([strong(text(i18n`maximum number of contained items`)), text(': '), text(`${i18n`this array may not contain more than ${schema[keyword`maxContains`]} items that validate against the schema:`} `), + constraints.push(paragraph([strong(text(i18n`maximum number of contained items`)), text(': '), text(`${i18n`this array may not contain more than ${String(schema[keyword`maxContains`])} items that validate against the schema:`} `), link(`${schema[keyword`contains`][s.slug]}.md`, i18n`check type definition`, text(gentitle(schema[keyword`contains`][s.titles], schema[keyword`contains`][keyword`type`])))])); }