mirror of
https://github.com/paricafe/misskey.git
synced 2024-11-25 09:36:44 -06:00
16 lines
514 B
JavaScript
16 lines
514 B
JavaScript
|
const loaderUtils = require('loader-utils');
|
||
|
|
||
|
function trim(text) {
|
||
|
return text.substring(1, text.length - 2);
|
||
|
}
|
||
|
|
||
|
module.exports = function(src) {
|
||
|
this.cacheable();
|
||
|
const options = loaderUtils.getOptions(this);
|
||
|
if (typeof options.search != 'string' || options.search.length == 0) console.error('invalid search');
|
||
|
if (typeof options.replace != 'function') console.error('invalid replacer');
|
||
|
src = src.replace(new RegExp(trim(options.search), 'g'), options.replace);
|
||
|
this.callback(null, src);
|
||
|
return src;
|
||
|
};
|