File tree Expand file tree Collapse file tree 2 files changed +2
-17
lines changed Expand file tree Collapse file tree 2 files changed +2
-17
lines changed Original file line number Diff line number Diff line change @@ -187,18 +187,6 @@ function svgBase64UrlToPngDataURL(base64UrlSvg: string): Promise<string> {
187187
188188 return new Promise ( ( resolve , reject ) => {
189189 try {
190- // 1. Convert Base64URL to standard Base64, then decode to SVG string
191- let base64 = base64UrlSvg
192- . split ( ',' )
193- . pop ( ) !
194- . replace ( / - / g, '+' )
195- . replace ( / _ / g, '/' ) ;
196- const padding = base64 . length % 4 ;
197- if ( padding ) {
198- base64 += '=' . repeat ( 4 - padding ) ;
199- }
200- const svgString = atob ( base64 ) ;
201-
202190 const img = new Image ( ) ;
203191
204192 img . onload = ( ) => {
@@ -234,11 +222,8 @@ function svgBase64UrlToPngDataURL(base64UrlSvg: string): Promise<string> {
234222 ) ;
235223 } ;
236224
237- // 2. Load SVG string into an Image element.
238- // The SVG string must be re-encoded to standard Base64 for the data URL.
239- // Alternatively, for non-Base64 SVG in data URL:
240- // img.src = 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svgString);
241- img . src = 'data:image/svg+xml;base64,' + btoa ( svgString ) ;
225+ // Load SVG string into an Image element
226+ img . src = base64UrlSvg ;
242227 } catch ( error ) {
243228 const message = error instanceof Error ? error . message : String ( error ) ;
244229 const errorMessage = `Error converting SVG to PNG: ${ message } ` ;
You can’t perform that action at this time.
0 commit comments