From f3955907e9fe249a6a7fad50e7237768926b215c Mon Sep 17 00:00:00 2001 From: "Dusan Mijatovic (PC2020)" Date: Wed, 12 Oct 2022 12:30:02 +0200 Subject: [PATCH] fix: remove doi internal value check from crossref method --- frontend/utils/getCrossref.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/frontend/utils/getCrossref.ts b/frontend/utils/getCrossref.ts index 6e9beb4a9..d81640a53 100644 --- a/frontend/utils/getCrossref.ts +++ b/frontend/utils/getCrossref.ts @@ -72,13 +72,16 @@ export async function getCrossrefItemByDoi(doi: string) { if (resp.status === 200) { const json: CrossrefResponse = await resp.json() - // find doi item - const doiItem = json.message.items.filter(item => item.DOI.toLowerCase() === doi.toLocaleLowerCase()) - // if found return it - if (doiItem.length === 1) { + // if found return item + if (json.message.items.length > 0) { return { status: 200, - message: doiItem[0] + message: json.message.items[0] + } + } else { + return { + status: 404, + message: 'DOI not found' } } }