From 0ad3b9670a9df66728c910c0bf5810261a686202 Mon Sep 17 00:00:00 2001 From: Chrystian Ruminowicz Date: Sun, 22 Jun 2025 20:04:41 +0200 Subject: [PATCH] fix(svg-export): prevent duplicated viewBox attribute --- src/index.android.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/index.android.ts b/src/index.android.ts index fcadb99..547f2f9 100644 --- a/src/index.android.ts +++ b/src/index.android.ts @@ -99,14 +99,19 @@ export class DrawingPad extends DrawingPadBase { if (!this.nativeView.isEmpty()) { const data: string = this.nativeView.getSignatureSvg(); - // Append viewbox to the svg for correct scaling - const svgHeaderRegEx = //i; - resolve( - data.replace( - svgHeaderRegEx, - `` - ) - ); + // Append viewbox to the svg for correct scaling (IF NEEDED) + if (data.indexOf('viewBox') === -1) { + const svgHeaderRegEx = //i; + resolve( + data.replace( + svgHeaderRegEx, + `` + ) + ); + } else { + resolve(data); + } + } else { reject('DrawingPad is empty.'); }