@@ -310,16 +310,16 @@ export class VscodeHatRenderer {
310310 let isOk = true ;
311311
312312 if (
313- svg . match ( / f i l l = " (? ! n o n e ) [ ^ " ] + " / ) == null &&
314- svg . match ( / f i l l : (? ! n o n e ) [ ^ ; ] + ; / ) == null
313+ svg . match ( / f i l l = " (? ! n o n e ) [ ^ " ] + " / u ) == null &&
314+ svg . match ( / f i l l : (? ! n o n e ) [ ^ ; ] + ; / u ) == null
315315 ) {
316316 void vscode . window . showErrorMessage (
317317 `Raw svg '${ shape } ' is missing 'fill' property` ,
318318 ) ;
319319 isOk = false ;
320320 }
321321
322- const viewBoxMatch = svg . match ( / v i e w B o x = " ( [ ^ " ] + ) " / ) ;
322+ const viewBoxMatch = svg . match ( / v i e w B o x = " ( [ ^ " ] + ) " / u ) ;
323323
324324 if ( viewBoxMatch == null ) {
325325 void vscode . window . showErrorMessage (
@@ -339,9 +339,9 @@ export class VscodeHatRenderer {
339339 // so that you can be notified if/when it changes or is removed.
340340 const [ fill , stroke ] = color . split ( "-" ) ;
341341 let svg = originalSvg
342- . replaceAll ( / f i l l = " (? ! n o n e ) [ ^ " ] + " / g , `fill="${ fill } "` )
343- . replaceAll ( / f i l l : (? ! n o n e ) [ ^ ; ] + ; / g , `fill:${ fill } ;` )
344- . replaceAll ( / \r ? \n / g , " " ) ;
342+ . replaceAll ( / f i l l = " (? ! n o n e ) [ ^ " ] + " / gu , `fill="${ fill } "` )
343+ . replaceAll ( / f i l l : (? ! n o n e ) [ ^ ; ] + ; / gu , `fill:${ fill } ;` )
344+ . replaceAll ( / \r ? \n / gu , " " ) ;
345345 if ( stroke !== undefined ) {
346346 svg = this . addInnerStrokeToSvg ( svgInfo , svg , stroke ) ;
347347 }
@@ -357,7 +357,7 @@ export class VscodeHatRenderer {
357357 stroke : string ,
358358 ) : string {
359359 // All hat svgs have exactly one path element. Extract it.
360- const pathRegex = / < p a t h [ ^ > ] * d = " ( [ ^ " ] + ) " [ ^ > ] * \/ > / ;
360+ const pathRegex = / < p a t h [ ^ > ] * d = " ( [ ^ " ] + ) " [ ^ > ] * \/ > / u ;
361361 const pathMatch = pathRegex . exec ( svg ) ;
362362 if ( ! pathMatch ) {
363363 console . error ( `Could not find path in svg: ${ svg } ` ) ;
@@ -446,9 +446,9 @@ export class VscodeHatRenderer {
446446 const newViewBoxString = `${ newViewBoxX } ${ newViewBoxY } ${ newViewBoxWidth } ${ newViewBoxHeight } ` ;
447447
448448 const innerSvg = rawSvg
449- . replace ( / w i d t h = " [ ^ " ] + " / , `` )
450- . replace ( / h e i g h t = " [ ^ " ] + " / , `` )
451- . replace ( / v i e w B o x = " ( [ ^ " ] + ) " / , `style="overflow:visible"` ) ;
449+ . replace ( / w i d t h = " [ ^ " ] + " / u , `` )
450+ . replace ( / h e i g h t = " [ ^ " ] + " / u , `` )
451+ . replace ( / v i e w B o x = " ( [ ^ " ] + ) " / u , `style="overflow:visible"` ) ;
452452
453453 const svg =
454454 `<svg xmlns="http://www.w3.org/2000/svg" ` +
@@ -469,12 +469,12 @@ export class VscodeHatRenderer {
469469 }
470470
471471 private getViewBoxDimensions ( rawSvg : string ) {
472- const viewBoxValue = rawSvg . match ( / v i e w B o x = " ( [ ^ " ] + ) " / ) ?. [ 1 ] ;
472+ const viewBoxValue = rawSvg . match ( / v i e w B o x = " ( [ ^ " ] + ) " / u ) ?. [ 1 ] ;
473473 if ( viewBoxValue == null ) {
474474 throw new Error ( "Missing viewBox" ) ;
475475 }
476476
477- const viewBoxParts = viewBoxValue . trim ( ) . split ( / \s + / ) ;
477+ const viewBoxParts = viewBoxValue . trim ( ) . split ( / \s + / u ) ;
478478 // A valid viewBox should have 4 parts: min-x, min-y, width and height
479479 if ( viewBoxParts . length !== 4 ) {
480480 throw new Error ( `Invalid viewBox format: ${ viewBoxValue } ` ) ;
0 commit comments