Skip to content

Commit

Permalink
Cairn.info: Serialize requests; fix PDF attachment URL
Browse files Browse the repository at this point in the history
- Serialize requests when translating multiple results (cf. #2983)
- Fix incorrect PDF attachment URL (always "undefined", because of
  taking a property of a string primitive)
  • Loading branch information
zoe-translates committed Oct 23, 2023
1 parent 9518fb4 commit 4f3f7c5
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions Cairn.info.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2022-05-31 18:42:02"
"lastUpdated": "2023-10-23 08:08:57"
}

/*
Expand Down Expand Up @@ -80,11 +80,9 @@ function getSearchResults(doc, checkOnly) {
async function doWeb(doc, url) {
if (await detectWeb(doc, url) == 'multiple') {
let items = await Zotero.selectItems(getSearchResults(doc, false));
if (items) {
await Promise.all(
Object.keys(items)
.map(url => requestDocument(url).then(scrape))
);
if (!items) return;
for (let url of Object.keys(items)) {
await scrape(await requestDocument(url));
}
}
else {
Expand Down Expand Up @@ -125,7 +123,7 @@ async function scrape(doc) {

if (pdfLink) {
item.attachments.push({
url: pdfLink.href,
url: pdfLink,
title: 'Full Text PDF',
mimeType: 'application/pdf'
});
Expand Down

0 comments on commit 4f3f7c5

Please sign in to comment.