Skip to content

Commit

Permalink
fix: only use the content URL from Crossref if the content type is set
Browse files Browse the repository at this point in the history
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
  • Loading branch information
thewilkybarkid committed Aug 16, 2021
1 parent 0dac056 commit 576e91d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion src/backend/utils/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ function searchCrossRef(handle: string): Promise<PreprintMetadata> {
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:
Expand Down

0 comments on commit 576e91d

Please sign in to comment.