diff --git a/js/modules/types/attachment.js b/js/modules/types/attachment.js index 11c313b86..27e7416b5 100644 --- a/js/modules/types/attachment.js +++ b/js/modules/types/attachment.js @@ -176,6 +176,12 @@ exports._replaceUnicodeOrderOverridesSync = (attachment) => { exports.replaceUnicodeOrderOverrides = async attachment => exports._replaceUnicodeOrderOverridesSync(attachment); +exports.removeSchemaVersion = async (attachment) => { + const attachmentWithoutSchemaVersion = Object.assign({}, attachment); + delete attachmentWithoutSchemaVersion.schemaVersion; + return attachmentWithoutSchemaVersion; +}; + // Public API const toVersion1 = exports.withSchemaVersion(1, autoOrientJPEG); const toVersion2 = exports.withSchemaVersion(2, exports.replaceUnicodeOrderOverrides); diff --git a/test/modules/types/attachment_test.js b/test/modules/types/attachment_test.js index 4de9d8526..bc79b3768 100644 --- a/test/modules/types/attachment_test.js +++ b/test/modules/types/attachment_test.js @@ -243,4 +243,26 @@ describe('Attachment', () => { } ); }); + + describe('removeSchemaVersion', () => { + it('should remove existing schema version', async () => { + const input = { + contentType: 'image/jpeg', + data: null, + fileName: 'foo.jpg', + size: 1111, + schemaVersion: 1, + }; + + const expected = { + contentType: 'image/jpeg', + data: null, + fileName: 'foo.jpg', + size: 1111, + }; + + const actual = await Attachment.removeSchemaVersion(input); + assert.deepEqual(actual, expected); + }); + }); });