summaryrefslogtreecommitdiff
path: root/webpack/loaders/replace.js
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-02-18 15:27:06 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-02-18 15:27:06 +0900
commit62fd58fbc8e7c0ed3ab8452c66694920793abe15 (patch)
tree2fe7298149458a9061882f2d311c78fe75658733 /webpack/loaders/replace.js
parentwip (diff)
downloadmisskey-62fd58fbc8e7c0ed3ab8452c66694920793abe15.tar.gz
misskey-62fd58fbc8e7c0ed3ab8452c66694920793abe15.tar.bz2
misskey-62fd58fbc8e7c0ed3ab8452c66694920793abe15.zip
wip
Diffstat (limited to 'webpack/loaders/replace.js')
-rw-r--r--webpack/loaders/replace.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/webpack/loaders/replace.js b/webpack/loaders/replace.js
index 4bb00a2abf..03cf1fcd78 100644
--- a/webpack/loaders/replace.js
+++ b/webpack/loaders/replace.js
@@ -1,17 +1,18 @@
const loaderUtils = require('loader-utils');
-function trim(text) {
- return text.substring(1, text.length - 2);
+function trim(text, g) {
+ return text.substring(1, text.length - (g ? 2 : 0));
}
module.exports = function(src) {
this.cacheable();
const options = loaderUtils.getOptions(this);
const search = options.search;
+ const g = search[search.length - 1] == 'g';
const replace = global[options.replace];
if (typeof search != 'string' || search.length == 0) console.error('invalid search');
if (typeof replace != 'function') console.error('invalid replacer:', replace, this.request);
- src = src.replace(new RegExp(trim(search), 'g'), replace);
+ src = src.replace(new RegExp(trim(search, g), g ? 'g' : ''), replace);
this.callback(null, src);
return src;
};