File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed
Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -202,25 +202,25 @@ export default function UploadPage() {
202202 } ;
203203
204204 const fixSvg = ( svg : string ) => {
205- // Find width and height in the <svg> tag
205+ // get width/ height
206206 const widthMatch = svg . match ( / w i d t h = " ( \d + ) " / ) ;
207207 const heightMatch = svg . match ( / h e i g h t = " ( \d + ) " / ) ;
208208
209209 if ( widthMatch && heightMatch ) {
210210 const width = widthMatch [ 1 ] ;
211211 const height = heightMatch [ 1 ] ;
212212
213- // If no viewBox exists, inject one
213+ // make width/height to 100%
214+ svg = svg
215+ . replace ( / w i d t h = " [ ^ " ] * " / , 'width="100%"' )
216+ . replace ( / h e i g h t = " [ ^ " ] * " / , 'height="100%"' ) ;
217+
218+ // add viewBox if missing
214219 if ( ! / v i e w B o x = / . test ( svg ) ) {
215220 svg = svg . replace (
216221 / < s v g ( [ ^ > ] * ) > / ,
217- `<svg$1 viewBox="0 0 ${ width } ${ height } " width="100%" height="100%">` ,
222+ `<svg$1 viewBox="0 0 ${ width } ${ height } ">`
218223 ) ;
219- } else {
220- // Still normalize width/height
221- svg = svg
222- . replace ( / w i d t h = " [ ^ " ] * " / , 'width="100%"' )
223- . replace ( / h e i g h t = " [ ^ " ] * " / , 'height="100%"' ) ;
224224 }
225225 }
226226
You can’t perform that action at this time.
0 commit comments