File tree Expand file tree Collapse file tree 1 file changed +10
-14
lines changed Expand file tree Collapse file tree 1 file changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -8,22 +8,18 @@ const HTMLRenderer: DocRenderer = ({ mainState: { currentDocument } }) => {
8
8
const b64String = currentDocument ?. fileData as string ;
9
9
10
10
let encoding = "" ;
11
- const bodyBase64 =
12
- b64String ?. replace (
13
- / ^ d a t a : t e x t \/ h t m l ; (?: c h a r s e t = ( [ ^ ; ] * ) ; ) ? b a s e 6 4 , / ,
14
- ( _ , charset ) => {
15
- encoding = charset ;
16
- return "" ;
17
- } ,
18
- ) || "" ;
11
+ const bodyBase64 = b64String ?. replace (
12
+ / ^ d a t a : t e x t \/ h t m l ; (?: c h a r s e t = ( [ ^ ; ] * ) ; ) ? b a s e 6 4 , / ,
13
+ ( _ , charset ) => {
14
+ encoding = charset || "utf-8" ;
15
+ return "" ;
16
+ } ,
17
+ ) ;
19
18
let body : string = window . atob ( bodyBase64 ) ;
20
19
21
- if ( encoding ) {
22
- // decode charset
23
- const buffer = new Uint8Array ( body . length ) ;
24
- for ( let i = 0 ; i < body . length ; i ++ ) buffer [ i ] = body . charCodeAt ( i ) ;
25
- body = new TextDecoder ( encoding ) . decode ( buffer ) ;
26
- }
20
+ // decode charset
21
+ const buffer = Uint8Array . from ( body , ( c ) => c . charCodeAt ( 0 ) ) ;
22
+ body = new TextDecoder ( encoding ) . decode ( buffer ) ;
27
23
28
24
const iframeCont = document . getElementById (
29
25
"html-body" ,
You can’t perform that action at this time.
0 commit comments