File tree 2 files changed +6
-1
lines changed
2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change 16
16
// https://github.com/ampedandwired/html-webpack-plugin#events
17
17
18
18
'use strict' ;
19
+ const escapeStringRegexp = require ( 'escape-string-regexp' ) ;
19
20
20
21
class InterpolateHtmlPlugin {
21
22
constructor ( replacements ) {
@@ -29,7 +30,10 @@ class InterpolateHtmlPlugin {
29
30
// Run HTML through a series of user-specified string replacements.
30
31
Object . keys ( this . replacements ) . forEach ( key => {
31
32
const value = this . replacements [ key ] ;
32
- data . html = data . html . replace ( '%' + key + '%' , value ) ;
33
+ data . html = data . html . replace (
34
+ new RegExp ( '%' + escapeStringRegexp ( key ) + '%' , 'g' ) ,
35
+ value
36
+ ) ;
33
37
} ) ;
34
38
callback ( null , data ) ;
35
39
}
Original file line number Diff line number Diff line change 22
22
],
23
23
"dependencies" : {
24
24
"chalk" : " 1.1.3" ,
25
+ "escape-string-regexp" : " 1.0.5" ,
25
26
"opn" : " 4.0.2"
26
27
},
27
28
"peerDependencies" : {
You can’t perform that action at this time.
0 commit comments