extraToCSL(): Fix "zoteroField[1] is undefined" on single-character field
E.g., "a:" on a line https://forums.zotero.org/discussion/82286/new-line-in-extra-field-induces-error-during-bibliography-generation
This commit is contained in:
parent
9919090901
commit
91ca6d2ba6
2 changed files with 6 additions and 1 deletions
|
@ -413,7 +413,7 @@ Zotero.Cite = {
|
|||
// convert to its associated CSL field
|
||||
var zoteroField = originalField.replace(/ ([A-Z])/, '$1');
|
||||
// If second character is lowercase (so not an acronym), lowercase first letter too
|
||||
if (zoteroField[1] == zoteroField[1].toLowerCase()) {
|
||||
if (zoteroField[1] && zoteroField[1] == zoteroField[1].toLowerCase()) {
|
||||
zoteroField = zoteroField[0].toLowerCase() + zoteroField.substr(1);
|
||||
}
|
||||
if (Zotero.Schema.CSL_FIELD_MAPPINGS_REVERSE[zoteroField]) {
|
||||
|
|
|
@ -41,5 +41,10 @@ describe("Zotero.Cite", function () {
|
|||
var str2 = 'DOI: 10.0/abc';
|
||||
assert.equal(Zotero.Cite.extraToCSL(str1), str2);
|
||||
});
|
||||
|
||||
it("should handle a single-character field name", function () {
|
||||
var str = 'a: ';
|
||||
assert.equal(Zotero.Cite.extraToCSL(str), str);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue