File tree 2 files changed +3
-2
lines changed
2 files changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ class LiteralTranspiler extends base.TranspilerBase {
99
99
var slashIdx = regExp . lastIndexOf ( '/' ) ;
100
100
var flags = regExp . substring ( slashIdx + 1 ) ;
101
101
regExp = regExp . substring ( 1 , slashIdx ) ; // cut off /.../ chars.
102
- regExp = regExp . replace ( '\'' , '\' + "\'" + r\'' ) ; // handle nested quotes by concatenation.
102
+ regExp = regExp . replace ( / ' / g , '\' + "\'" + r\'' ) ; // handle nested quotes by concatenation.
103
103
this . emitNoSpace ( regExp ) ;
104
104
this . emitNoSpace ( '\'' ) ;
105
105
if ( flags . indexOf ( 'g' ) === - 1 ) {
@@ -133,4 +133,4 @@ class LiteralTranspiler extends base.TranspilerBase {
133
133
}
134
134
}
135
135
136
- export = LiteralTranspiler ;
136
+ export = LiteralTranspiler ;
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ describe('literals', () => {
43
43
it ( 'translates regexp literals' , ( ) => {
44
44
expectTranslate ( '/wo\\/t?/g' ) . to . equal ( ' new RegExp ( r\'wo\\/t?\' ) ;' ) ;
45
45
expectTranslate ( '/\'/g' ) . to . equal ( ' new RegExp ( r\'\' + "\'" + r\'\' ) ;' ) ;
46
+ expectTranslate ( '/\'o\'/g' ) . to . equal ( ' new RegExp ( r\'\' + "\'" + r\'o\' + "\'" + r\'\' ) ;' ) ;
46
47
expectTranslate ( '/abc/gmi' )
47
48
. to . equal ( ' new RegExp ( r\'abc\' , multiline: true , caseSensitive: false ) ;' ) ;
48
49
expectErroneousCode ( '/abc/' ) . to . throw ( / R e g u l a r E x p r e s s i o n s m u s t u s e t h e \/ \/ g f l a g / ) ;
You can’t perform that action at this time.
0 commit comments