Skip to content

Commit

Permalink
NASA ADS: Fix PDF URL race condition
Browse files Browse the repository at this point in the history
Rather than assuming that RIS processing will complete in the same order
that it begins, we use items' URLs.
  • Loading branch information
AbeJellinek committed Jun 15, 2021
1 parent 875dc98 commit de8cbf8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions NASA ADS.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2021-06-15 15:35:37"
"lastUpdated": "2021-06-15 15:43:55"
}

/*
Expand Down Expand Up @@ -53,7 +53,7 @@ function getSearchResults(doc) {
}

function extractId(url) {
return /\/abs\/(.*)\/abstract/.exec(url)[1];
return /\/abs\/([^/]+)/.exec(url)[1];
}

function getTypeFromId(id) {
Expand Down Expand Up @@ -109,7 +109,7 @@ function scrape(ids, doc) {
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); // RIS
translator.setString(json.export);
translator.setHandler("itemDone", function (obj, item) {
const id = ids.pop();
const id = extractId(item.url);
item.itemType = getTypeFromId(id);
item.attachments.push({
url: makePdfUrl(id),
Expand Down

0 comments on commit de8cbf8

Please sign in to comment.