Skip to content

Commit 040e32f

Browse files
author
Ben
authored
Update ParseFile.js
Tabs to spaces, removed base64 string validation
1 parent ce73a6e commit 040e32f

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/ParseFile.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export type FileSource = {
2424
};
2525

2626
var dataUriRegexp =
27-
/^data:([a-zA-Z]*\/[a-zA-Z+.-]*);(charset=[a-zA-Z0-9\-\/\s]*,)?base64,(\S+)/;
27+
/^data:([a-zA-Z]*\/[a-zA-Z+.-]*);(charset=[a-zA-Z0-9\-\/\s]*,)?base64,/;
2828

2929
function b64Digit(number: number): string {
3030
if (number < 26) {
@@ -99,15 +99,10 @@ export default class ParseFile {
9999
type: specifiedType
100100
};
101101
} else if (data && data.hasOwnProperty('base64')) {
102-
var commaIndex = data.base64.indexOf(',');
103-
try {
104-
window.atob(commaIndex === -1?data.base64:data.base64.slice(commaIndex + 1));
105-
} catch(e) {
106-
throw new TypeError('Cannot create a Parse.File with that data.');
107-
}
102+
var commaIndex = data.base64.indexOf(',');
108103

109104
if (commaIndex !== -1) {
110-
var matches = dataUriRegexp.exec(data.base64.slice(0, 100));
105+
var matches = dataUriRegexp.exec(data.base64.slice(0, commaIndex + 1));
111106
// if data URI with type and charset, there will be 4 matches.
112107
this._source = {
113108
format: 'base64',

0 commit comments

Comments
 (0)