Skip to content

Commit

Permalink
remove duplicate reference keys
Browse files Browse the repository at this point in the history
  • Loading branch information
mfenner committed Apr 22, 2024
1 parent 4ccb4a0 commit 4e1b935
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion crossref/crossref.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,13 +508,19 @@ func ReadCrossref(content Content) (types.Data, error) {
}

for _, v := range content.Reference {
data.References = append(data.References, types.Reference{
reference := types.Reference{
Key: v.Key,
ID: doiutils.NormalizeDOI(v.DOI),
Title: v.ArticleTitle,
PublicationYear: v.Year,
Unstructured: v.Unstructured,
}
containsKey := slices.ContainsFunc(data.References, func(e types.Reference) bool {
return e.Key != "" && e.Key == reference.Key
})
if !containsKey {
data.References = append(data.References, reference)
}
}

fields := reflect.VisibleFields(reflect.TypeOf(content.Relation))
Expand Down

0 comments on commit 4e1b935

Please sign in to comment.