Commit e41d671b authored by Ville Immonen's avatar Ville Immonen Committed by Dan Abramov
Browse files

Fix InterpolateHtmlPlugin only replacing the first occurrence (#731)

Fixes https://github.com/facebookincubator/create-react-app/issues/625#issuecomment-249320724.
parent 500fb749
No related merge requests found
Showing with 6 additions and 1 deletion
+6 -1
......@@ -16,6 +16,7 @@
// https://github.com/ampedandwired/html-webpack-plugin#events
'use strict';
const escapeStringRegexp = require('escape-string-regexp');
class InterpolateHtmlPlugin {
constructor(replacements) {
......@@ -29,7 +30,10 @@ class InterpolateHtmlPlugin {
// Run HTML through a series of user-specified string replacements.
Object.keys(this.replacements).forEach(key => {
const value = this.replacements[key];
data.html = data.html.replace('%' + key + '%', value);
data.html = data.html.replace(
new RegExp('%' + escapeStringRegexp(key) + '%', 'g'),
value
);
});
callback(null, data);
}
......
......@@ -22,6 +22,7 @@
],
"dependencies": {
"chalk": "1.1.3",
"escape-string-regexp": "1.0.5",
"opn": "4.0.2"
},
"peerDependencies": {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment