Skip to content

Commit

Permalink
Use PMID endpoint instead of web translator
Browse files Browse the repository at this point in the history
Use PMID endpoint instead of web translator
for pubmed links as this is the more "polite"
way of accessing PubMed.

Change-Id: Ic3c1a661db65ddc5442f9eaae580275b4fa3499f
  • Loading branch information
mvolz committed Sep 11, 2023
1 parent cf96d57 commit fffe3e4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/webSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ WebSession.prototype.handleURL = async function () {
await SearchEndpoint.handleIdentifier(this.ctx, { DOI: doi });
return;
}
let pmid = this.cleanPMIDFromURL(url);
if (pmid) {
await SearchEndpoint.handleIdentifier(this.ctx, { PMID: pmid});
return;
}
}

var responseTypeMap = new Map([
Expand Down Expand Up @@ -469,3 +474,12 @@ WebSession.prototype.cleanDOIFromURL = function (url) {
}
return doi || null;
};

WebSession.prototype.cleanPMIDFromURL = function (url) {
let pmid = null;
let pmidMatch = decodeURIComponent(url).match(/^https?:\/\/www.ncbi.nlm.nih.gov\/pubmed\/(\d+)\/?/);
if (pmidMatch) {
pmid = pmidMatch[0];
}
return pmid;
};

0 comments on commit fffe3e4

Please sign in to comment.