diff --git a/src/ParseFile.js b/src/ParseFile.js index 0cc4e7d62..4498456ce 100644 --- a/src/ParseFile.js +++ b/src/ParseFile.js @@ -43,7 +43,7 @@ export type FileSource = }; const base64Regex = new RegExp( - '([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))', + '([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/][AQgw]==)|([0-9a-zA-Z+/]{2}[AEIMQUYcgkosw048]=)|([0-9a-zA-Z+/]{4}))', 'i' ); diff --git a/src/__tests__/ParseFile-test.js b/src/__tests__/ParseFile-test.js index fb045dbc3..31bfb7cc6 100644 --- a/src/__tests__/ParseFile-test.js +++ b/src/__tests__/ParseFile-test.js @@ -60,7 +60,19 @@ describe('ParseFile', () => { process.env.PARSE_BUILD = 'node'; }); - it('can create files with base64 encoding', () => { + it('can create files with base64 encoding (no padding)', () => { + const file = new ParseFile('parse.txt', { base64: 'YWJj' }); + expect(file._source.base64).toBe('YWJj'); + expect(file._source.type).toBe(''); + }); + + it('can create files with base64 encoding (1 padding)', () => { + const file = new ParseFile('parse.txt', { base64: 'YWI=' }); + expect(file._source.base64).toBe('YWI='); + expect(file._source.type).toBe(''); + }); + + it('can create files with base64 encoding (2 padding)', () => { const file = new ParseFile('parse.txt', { base64: 'ParseA==' }); expect(file._source.base64).toBe('ParseA=='); expect(file._source.type).toBe('');