From 576e91de24b5679f7caa725fc09e4f9a60c81075 Mon Sep 17 00:00:00 2001 From: Chris Wilkinson Date: Mon, 16 Aug 2021 13:38:14 +0100 Subject: [PATCH] fix: only use the content URL from Crossref if the content type is set Turns out the failures I've been seeing in CI are the result having triggered a bug locally: it should not be possible to see a HTML page embedded, only a PDF. The metadata resolver was finding a content URL from Crossref (HTML) but using the content type from Google Scholar (PDF). This tries to group the content URL and type in the Crossref response together, so it uses both of them together or neither. Refs #388 --- .../preprint-Desktop-Chrome-linux.png | 4 ++-- .../preprint-iPhone-11-linux.png | 4 ++-- src/backend/utils/resolve.ts | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/integration/src/finding-a-review.spec.ts-snapshots/preprint-Desktop-Chrome-linux.png b/integration/src/finding-a-review.spec.ts-snapshots/preprint-Desktop-Chrome-linux.png index 601a9de5..b5d4995e 100644 --- a/integration/src/finding-a-review.spec.ts-snapshots/preprint-Desktop-Chrome-linux.png +++ b/integration/src/finding-a-review.spec.ts-snapshots/preprint-Desktop-Chrome-linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:378370f44765ca994bb6082465627e38170868c8e229bce9ed163914091dc039 -size 206806 +oid sha256:b3cf0e528cc967e4081a8bfb832aa1a24a7207f1a51ef673ad953f3ebb16d22c +size 344738 diff --git a/integration/src/finding-a-review.spec.ts-snapshots/preprint-iPhone-11-linux.png b/integration/src/finding-a-review.spec.ts-snapshots/preprint-iPhone-11-linux.png index 63833184..00fe3675 100644 --- a/integration/src/finding-a-review.spec.ts-snapshots/preprint-iPhone-11-linux.png +++ b/integration/src/finding-a-review.spec.ts-snapshots/preprint-iPhone-11-linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:245b02060dc5bb3d563cfa045b226b487c19d49a69dd172fcf822ba4fc6a79e7 -size 429550 +oid sha256:921491a4bce3f3d3681d595dbd88d46b3b1fe3e28e440f182fc3a2c03b57e790 +size 602742 diff --git a/src/backend/utils/resolve.ts b/src/backend/utils/resolve.ts index e0d903f8..d2c008c7 100644 --- a/src/backend/utils/resolve.ts +++ b/src/backend/utils/resolve.ts @@ -186,7 +186,9 @@ function searchCrossRef(handle: string): Promise { license: undefined, publication: res.publisher, contentUrl: - Array.isArray(res.link) && res.link.length > 0 + Array.isArray(res.link) && + res.link.length > 0 && + res.link[0]['content-type'] !== 'unspecified' ? res.link[0].URL : undefined, contentEncoding: