Improve truncateFileName
logic for edge cases
This commit is contained in:
parent
89d81cee41
commit
63205a73e8
1 changed files with 6 additions and 0 deletions
|
@ -1230,6 +1230,12 @@ Zotero.File = new function(){
|
|||
ext = '.' + ext;
|
||||
}
|
||||
|
||||
if (ext.length >= maxLength) {
|
||||
// Improve resulting truncated filename by dropping extension if it wouldn't fit within
|
||||
// the limit. e.g. for (lorem.json, 5) it returns "lorem", instead of ".json"
|
||||
ext = '';
|
||||
}
|
||||
|
||||
return fn.substr(0,maxLength-ext.length) + ext;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue