Trim leading/trailing space in filename format string. Fix #3701

This commit is contained in:
Tom Najdek 2024-02-16 10:14:45 +01:00
parent f548efde15
commit abe8def0f1
No known key found for this signature in database
GPG key ID: EEC61A7B4C667D77
2 changed files with 9 additions and 0 deletions

View file

@ -2146,6 +2146,8 @@ Zotero.Attachments = new function () {
formatString = Zotero.Prefs.get('attachmentRenameTemplate');
}
formatString = formatString.trim();
const getSlicedCreatorsOfType = (creatorType, slice) => {
let creatorTypeIDs;
switch (creatorType) {

View file

@ -1547,6 +1547,13 @@ describe("Zotero.Attachments", function() {
);
});
it("should trim spaces from template string", function () {
assert.equal(
Zotero.Attachments.getFileBaseNameFromItem(itemBookSection, ' {{ bookTitle case="snake" }} '),
'book_title'
);
});
it("should convert old attachmentRenameFormatString to use new attachmentRenameTemplate syntax", function () {
assert.equal(
Zotero.Prefs.convertLegacyAttachmentRenameFormatString('{%c - }{%y - }{%t{50}}'),