Skip to content

Commit

Permalink
fix: Fix attachment uploading issue caused by ES2022 spread operator
Browse files Browse the repository at this point in the history
Per ES2022, keys with undefined values are applied via the spread, overwriting any existing value.  This impacts us here because `attachment` has optional `name` and `path` fields.  So need to take care to only apply them when they exist.
  • Loading branch information
baumandm committed Jan 8, 2024
1 parent d42791c commit 87ae1d3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/backend/src/resolvers/attachment.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ export class AttachmentResolver {
const mimeType = await getTypeAsync({ fileName: file.filename, stream });

return {
name: file.filename,
path: file.filename,
...attachment,
mimeType,
...attachment
name: attachment.name ?? file.filename,
path: attachment.path ?? file.filename
};
} catch (error: any) {
logger.error(error);
Expand Down

0 comments on commit 87ae1d3

Please sign in to comment.