Skip to content

Commit

Permalink
allow references without id
Browse files Browse the repository at this point in the history
  • Loading branch information
mfenner committed Jan 25, 2025
1 parent be4df97 commit 4683dcd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "commonmeta",
Version: "v0.6.37",
Version: "v0.6.38",
Short: "Convert scholarly metadata from one format to another",
Long: `Convert scholarly metadata between formats. Currently
supported input formats are Crossref and DataCite DOIs, currently
Expand Down
27 changes: 12 additions & 15 deletions jsonfeed/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,21 +408,18 @@ func Read(content Content) (commonmeta.Data, error) {
}

for _, v := range content.Reference {
_, idtype := utils.ValidateID(v.ID)
if idtype == "DOI" || idtype == "URL" {
reference := commonmeta.Reference{
Key: v.Key,
ID: v.ID,
Title: v.Title,
PublicationYear: v.PublicationYear,
Unstructured: v.Unstructured,
}
containsKey := slices.ContainsFunc(data.References, func(e commonmeta.Reference) bool {
return e.Key != "" && e.Key == reference.Key
})
if !containsKey {
data.References = append(data.References, reference)
}
reference := commonmeta.Reference{
Key: v.Key,
ID: v.ID,
Title: v.Title,
PublicationYear: v.PublicationYear,
Unstructured: v.Unstructured,
}
containsKey := slices.ContainsFunc(data.References, func(e commonmeta.Reference) bool {
return e.Key != "" && e.Key == reference.Key
})
if !containsKey {
data.References = append(data.References, reference)
}
}

Expand Down

0 comments on commit 4683dcd

Please sign in to comment.