From 4764791944ae8ef75121644f8d54a773333e1e05 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 23 Aug 2025 06:48:15 +0000 Subject: [PATCH 1/2] XML --- src/article/converter/jats/internal2jats.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/article/converter/jats/internal2jats.js b/src/article/converter/jats/internal2jats.js index 9675e3ce9..c99f81bac 100644 --- a/src/article/converter/jats/internal2jats.js +++ b/src/article/converter/jats/internal2jats.js @@ -394,21 +394,21 @@ function _exportDate ($$, node, prop, dateType, tag) { const el = $$(tagName).attr('date-type', dateType) .attr('iso-8601-date', date) - const year = date.split('-')[0] - const month = date.split('-')[1] - const day = date.split('-')[2] if (_isDateValid(date)) { + const [year, month, day] = date.split('-') el.append( $$('day').append(day), $$('month').append(month), $$('year').append(year) ) } else if (_isYearMonthDateValid(date)) { + const [year, month] = date.split('-') el.append( $$('month').append(month), $$('year').append(year) ) } else if (_isYearDateValid(date)) { + const [year] = date.split('-') el.append( $$('year').append(year) ) From be838f57cbcf7108202104d357abfcc021c74144 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 23 Aug 2025 06:48:53 +0000 Subject: [PATCH 2/2] Fix(export): Make date export in internal2jats.js more robust The original _exportDate function called `date.split('-')` before validating the format of the date string. This could lead to `month` or `day` variables being `undefined` if the date string was not in the expected format. Passing `undefined` to the XML element's `append` method likely caused a runtime error, preventing the XML from being generated. This commit refactors the function to only parse the year, month, and day from the date string after the string has been successfully validated against a corresponding format (YYYY-MM-DD, YYYY-MM, or YYYY). This prevents runtime errors from invalid date formats during XML export.