diff --git a/lib/jsdoc/src/filter.js b/lib/jsdoc/src/filter.js index f260a458..206206a3 100644 --- a/lib/jsdoc/src/filter.js +++ b/lib/jsdoc/src/filter.js @@ -11,6 +11,16 @@ var path = require('jsdoc/path'); var pwd = env.pwd; +function makeRegExp(config) { + var regExp = null; + + if (config) { + regExp = (typeof config === 'string') ? new RegExp(config) : config; + } + + return regExp; +} + /** @constructor @param {object} opts @@ -24,12 +34,8 @@ exports.Filter = function(opts) { return path.resolve(pwd, $); }) : null; - this.includePattern = opts.includePattern? - typeof opts.includePattern === 'string'? new RegExp(opts.includePattern) : opts.includePattern - : null; - this.excludePattern = opts.excludePattern? - typeof opts.excludePattern === 'string'? new RegExp(opts.excludePattern) : opts.excludePattern - : null; + this.includePattern = makeRegExp(opts.includePattern); + this.excludePattern = makeRegExp(opts.excludePattern); }; /**