Skip to content

Commit d94b271

Browse files
committed
less complicated code
1 parent 3458907 commit d94b271

File tree

2 files changed

+2
-17
lines changed

2 files changed

+2
-17
lines changed

tools/server/public/index.html.gz

-34 Bytes
Binary file not shown.

tools/server/webui/src/components/useChatExtraContext.tsx

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff 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}`;

0 commit comments

Comments
 (0)