Skip to content

Commit

Permalink
fix bug where empty array from crossref.go
Browse files Browse the repository at this point in the history
  • Loading branch information
tmwclaxton committed Feb 8, 2024
1 parent 3ca0300 commit cbb4b67
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions internal/parsing/crossref.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,23 @@ func CrossRefDataDOI(doi string) (*TidyCrossRefResponse, error) {

// Extract data from the response
item := crossRefResponse.Message
title := ""
// check if title > 0
if len(item.Title) > 0 {
title = item.Title[0]
}
issn := ""
// check if title > 0
if len(item.ISSN) > 0 {
issn = item.ISSN[0]
}

tidyCrossRefResponse := &TidyCrossRefResponse{
Title: item.Title[0],
Title: title,
Year: fmt.Sprintf("%d", item.Issued.DateParts[0][0]), // assuming the date-parts contain the year
Abstract: item.Abstract,
DOI: item.DOI,
ISSN: item.ISSN[0],
ISSN: issn,
}

if tidyCrossRefResponse.Abstract != "" {
Expand Down

0 comments on commit cbb4b67

Please sign in to comment.