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();
|
||||
|
||||
@@ -122,7 +122,7 @@ class Configuration
|
||||
'js/kjua-0.10.0.js' => 'sha512-BYj4xggowR7QD150VLSTRlzH62YPfhpIM+b/1EUEr7RQpdWAGKulxWnOvjFx1FUlba4m6ihpNYuQab51H6XlYg==',
|
||||
'js/legacy.js' => 'sha512-rGXYUpIqbFoHAgBXZ0UlJBdNAIMOC9EQ67MG0X46D5uRB8LvwzgKirbSQRGdYfk8I2jsUcm+tvHXYboUnC6DUg==',
|
||||
'js/prettify.js' => 'sha512-puO0Ogy++IoA2Pb9IjSxV1n4+kQkKXYAEUtVzfZpQepyDPyXk8hokiYDS7ybMogYlyyEIwMLpZqVhCkARQWLMg==',
|
||||
'js/privatebin.js' => 'sha512-a8zeCawerrfYBa3x0fiaqZMtR1k9Fd0ZKMl2rhR2M7q25dGHDaoZOzn5xk9AiNHR+Enn7srauqOxnnI1XlooCw==',
|
||||
'js/privatebin.js' => 'sha512-2ybiXcPP5nF8Vv5mD03EW9jCQEC25adiwp+nMRELSSXCAL1KErWMYS9mVOsUeRSlvnzHrRw19DGpF0gmIZFXbw==',
|
||||
'js/purify-3.3.0.js' => 'sha512-lsHD5zxs4lu/NDzaaibe27Vd2t7Cy9JQ3qDHUvDfb4oZvKoWDNEhwUY+4bT3R68cGgpgCYp8U1x2ifeVxqurdQ==',
|
||||
'js/showdown-2.1.0.js' => 'sha512-WYXZgkTR0u/Y9SVIA4nTTOih0kXMEd8RRV6MLFdL6YU8ymhR528NLlYQt1nlJQbYz4EW+ZsS0fx1awhiQJme1Q==',
|
||||
'js/zlib-1.3.1-1.js' => 'sha512-5bU9IIP4PgBrOKLZvGWJD4kgfQrkTz8Z3Iqeu058mbQzW3mCumOU6M3UVbVZU9rrVoVwaW4cZK8U8h5xjF88eQ==',
|
||||
|
||||
Reference in New Issue
Block a user