File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
packages/mf2-messageformat/src/data-model Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -109,13 +109,18 @@ function stringifyPattern(pattern: Pattern, quoted: boolean) {
109109 quoted = true ;
110110 }
111111 for ( const el of pattern ) {
112- if ( typeof el === 'string' ) res += el ;
112+ if ( typeof el === 'string' ) res += stringifyString ( el , quoted ) ;
113113 else if ( el . type === 'markup' ) res += stringifyMarkup ( el ) ;
114114 else res += stringifyExpression ( el ) ;
115115 }
116116 return quoted ? `{{${ res } }}` : res ;
117117}
118118
119+ function stringifyString ( str : string , quoted : boolean ) {
120+ const esc = quoted ? / [ \\ | ] / g : / [ \\ { } ] / g;
121+ return str . replace ( esc , '\\$&' ) ;
122+ }
123+
119124function stringifyExpression ( { arg, annotation, attributes } : Expression ) {
120125 let res : string ;
121126 switch ( arg ?. type ) {
You can’t perform that action at this time.
0 commit comments