Patch for stripping whitespace or "doi:" from DOI lookups
When I use the "Add item by identifier" (magic wand) function on a DOI it's annoying that it doesn't strip out any leading whitespace or "doi:".
That can be fixed in lookup.js by changing line 6+ from
if(identifier.substr(0, 3) == "10.") {
var item = {itemType:"journalArticle", DOI:identifier};
to
var doistart = identifier.indexOf("10.")
if(doistart >= 0) {
var doi = identifier.substr(doistart)
var item = {itemType:"journalArticle", DOI:doi};
This doesn't change the handling of ISBN/PMIDs ("10." is not valid in either) and it does the trick. If no one protests, can someone with access apply the patch?
That can be fixed in lookup.js by changing line 6+ from
if(identifier.substr(0, 3) == "10.") {
var item = {itemType:"journalArticle", DOI:identifier};
to
var doistart = identifier.indexOf("10.")
if(doistart >= 0) {
var doi = identifier.substr(doistart)
var item = {itemType:"journalArticle", DOI:doi};
This doesn't change the handling of ISBN/PMIDs ("10." is not valid in either) and it does the trick. If no one protests, can someone with access apply the patch?
-
dstillmanI've applied a variation of this that uses a utility function we have that pulls a DOI out of a string using a regex regardless of what's around it. Thanks.