Skip to content

Commit

Permalink
refactor: simplify code (#474)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored and hiroppy committed Sep 28, 2019
1 parent 41038fb commit 43eef21
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@ const defaults = {
module.exports = function wdm(compiler, opts) {
const options = Object.assign({}, defaults, opts);

if (options.lazy) {
if (typeof options.filename === 'string') {
const filename = options.filename
.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&') // eslint-disable-line no-useless-escape
.replace(/\\\[[a-z]+\\\]/gi, '.+');

options.filename = new RegExp(`^[/]{0,1}${filename}$`);
}
}

// defining custom MIME type
if (options.mimeTypes) {
const typeMap = options.mimeTypes.typeMap || options.mimeTypes;
Expand All @@ -57,6 +47,14 @@ module.exports = function wdm(compiler, opts) {
}
});
} else {
if (typeof options.filename === 'string') {
const filename = options.filename
.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&') // eslint-disable-line no-useless-escape
.replace(/\\\[[a-z]+\\\]/gi, '.+');

options.filename = new RegExp(`^[/]{0,1}${filename}$`);
}

context.state = true;
}

Expand Down

0 comments on commit 43eef21

Please sign in to comment.