File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ export type FileSource = {
24
24
} ;
25
25
26
26
var dataUriRegexp =
27
- / ^ d a t a : ( [ a - z A - Z ] * \/ [ a - z A - Z + . - ] * ) ; ( c h a r s e t = [ a - z A - Z 0 - 9 \- \/ \s ] * , ) ? b a s e 6 4 , ( \S + ) / ;
27
+ / ^ d a t a : ( [ a - z A - Z ] * \/ [ a - z A - Z + . - ] * ) ; ( c h a r s e t = [ a - z A - Z 0 - 9 \- \/ \s ] * , ) ? b a s e 6 4 , / ;
28
28
29
29
function b64Digit ( number : number ) : string {
30
30
if ( number < 26 ) {
@@ -99,12 +99,14 @@ export default class ParseFile {
99
99
type : specifiedType
100
100
} ;
101
101
} else if ( data && data . hasOwnProperty ( 'base64' ) ) {
102
- var matches = dataUriRegexp . exec ( data . base64 ) ;
103
- if ( matches && matches . length > 0 ) {
102
+ var commaIndex = data . base64 . indexOf ( ',' ) ;
103
+
104
+ if ( commaIndex !== - 1 ) {
105
+ var matches = dataUriRegexp . exec ( data . base64 . slice ( 0 , commaIndex + 1 ) ) ;
104
106
// if data URI with type and charset, there will be 4 matches.
105
107
this . _source = {
106
108
format : 'base64' ,
107
- base64 : matches . length === 4 ? matches [ 3 ] : matches [ 2 ] ,
109
+ base64 : data . base64 . slice ( commaIndex + 1 ) ,
108
110
type : matches [ 1 ]
109
111
} ;
110
112
} else {
You can’t perform that action at this time.
0 commit comments