1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-27 12:36:14 +01:00

Fix: don't check filename by index when listing attachments (#224)

* don't check filename by index

* Fix: Filter by exact matches
This commit is contained in:
Ben Mezger (seds) 2021-02-03 15:06:39 -03:00 committed by GitHub
parent 57f7cf607a
commit 116d7a4062
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -266,11 +266,17 @@ export class GetCommand extends DownloadCommand {
return Response.error('No attachments available for this item.');
}
const attachments = cipher.attachments.filter((a) => a.id.toLowerCase() === id ||
let attachments = cipher.attachments.filter((a) => a.id.toLowerCase() === id ||
(a.fileName != null && a.fileName.toLowerCase().indexOf(id) > -1));
if (attachments.length === 0) {
return Response.error('Attachment `' + id + '` was not found.');
}
const exactMatches = attachments.filter((a) => a.fileName.toLowerCase() === id)
if (exactMatches.length === 1) {
attachments = exactMatches;
}
if (attachments.length > 1) {
return Response.multipleResults(attachments.map((a) => a.id));
}