Skip to content

Commit

Permalink
Guard against missing cmr_data_formats
Browse files Browse the repository at this point in the history
  • Loading branch information
Tammo-Feldmann committed Jul 3, 2024
1 parent 8230c5a commit f0299a5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,13 @@ exports.createResolvers = ({ createResolvers }) => {
doi: {
cmr_data_formats: {
resolve: source => {
if (!source.cmr_data_formats) return null
// parse strings and log errors for arrays in string format
return typeof source.cmr_data_formats === "string"
? source.cmr_data_formats &&
!source.cmr_data_formats.includes("null") &&
source.cmr_data_formats.split("[")[1]
source.cmr_data_formats.includes("['") &&
source.cmr_data_formats.includes("']")
? source.cmr_data_formats
?.split("[")[1]
.split("]")[0]
Expand All @@ -330,7 +332,7 @@ exports.createResolvers = ({ createResolvers }) => {
)
.filter(f => f !== "")
: []
: source.cmr_data_formats.filter(f => f !== "")
: source.cmr_data_formats?.filter(f => f !== "")
},
},
cmr_science_keywords: {
Expand Down

0 comments on commit f0299a5

Please sign in to comment.