Better (and centralized) DOI parsing
This commit is contained in:
parent
6a28e8b040
commit
51f6e1650d
3 changed files with 13 additions and 3 deletions
|
@ -265,7 +265,7 @@
|
|||
var doi = this.item.getField('DOI');
|
||||
if (doi) {
|
||||
// Pull out DOI, in case there's a prefix
|
||||
doi = doi.match(/10\..*/);
|
||||
doi = Zotero.Utilities.prototype.cleanDOI(doi);;
|
||||
if (doi) {
|
||||
spec = "http://dx.doi.org/" + encodeURIComponent(doi);
|
||||
}
|
||||
|
@ -454,7 +454,7 @@
|
|||
}
|
||||
else if (fieldName == 'DOI' && val) {
|
||||
// Pull out DOI, in case there's a prefix
|
||||
var doi = val.match(/10\..*/);
|
||||
var doi = Zotero.Utilities.prototype.cleanDOI(val);
|
||||
if (doi) {
|
||||
doi = "http://dx.doi.org/" + encodeURIComponent(doi);
|
||||
label.setAttribute("isButton", true);
|
||||
|
|
|
@ -1962,7 +1962,7 @@ var ZoteroPane = new function()
|
|||
var doi = item.getField('DOI');
|
||||
if (doi) {
|
||||
// Pull out DOI, in case there's a prefix
|
||||
doi = doi.match(/10\..*/);
|
||||
doi = Zotero.Utilities.prototype.cleanDOI(doi);
|
||||
if (doi) {
|
||||
uri = "http://dx.doi.org/" + encodeURIComponent(doi);
|
||||
}
|
||||
|
|
|
@ -143,6 +143,16 @@ Zotero.Utilities.prototype.cleanTags = function(/**String*/ x) {
|
|||
return x.replace(/<[^>]+>/g, "");
|
||||
}
|
||||
|
||||
|
||||
Zotero.Utilities.prototype.cleanDOI = function(/**String**/ x) {
|
||||
if(typeof(x) != "string") {
|
||||
throw "cleanDOI: argument must be a string";
|
||||
}
|
||||
|
||||
return x.match(/10\.[^\s\/]+\/[^\s]+/);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Encode special XML/HTML characters<br/>
|
||||
* <br/>
|
||||
|
|
Loading…
Reference in a new issue