mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2026-03-05 13:30:32 -05:00
address unneeded defensive code lint
IMHO this check is actually necessary, as we do call the function with an empty argument. So we need a guard there, but we could simplify it a bit, by making the argument an empty array by default. I still kept the check for undefined (line 3249, first check) in case the caller passes us an undefined variable. See: https://github.com/PrivateBin/PrivateBin/security/quality/rules/js%2Funneeded-defensive-code - Copilot suggested to simply remove the if-condition and its else block, which I think is wrong.
This commit is contained in:
@@ -3234,7 +3234,7 @@ jQuery.PrivateBin = (function($) {
|
||||
* @param {FileList[]} loadedFiles (optional) loaded files array
|
||||
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/FileReader#readAsDataURL()}
|
||||
*/
|
||||
function readFileData(loadedFiles) {
|
||||
function readFileData(loadedFiles = []) {
|
||||
// Clear old cache
|
||||
me.removeAttachmentData();
|
||||
|
||||
@@ -3246,15 +3246,15 @@ jQuery.PrivateBin = (function($) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (loadedFiles === undefined) {
|
||||
loadedFiles = [...$fileInput[0].files];
|
||||
me.clearDragAndDrop();
|
||||
} else {
|
||||
if (loadedFiles && loadedFiles.length > 0) {
|
||||
const fileNames = loadedFiles.map((loadedFile => loadedFile.name));
|
||||
printDragAndDropFileNames(fileNames);
|
||||
} else {
|
||||
loadedFiles = [...$fileInput[0].files];
|
||||
me.clearDragAndDrop();
|
||||
}
|
||||
|
||||
if (typeof loadedFiles !== 'undefined') {
|
||||
if (loadedFiles.length > 0) {
|
||||
files = loadedFiles;
|
||||
loadedFiles.forEach((loadedFile, index) => {
|
||||
const fileReader = new FileReader();
|
||||
|
||||
Reference in New Issue
Block a user