Skip to content

Commit

Permalink
fix(config): ignore empty string patterns
Browse files Browse the repository at this point in the history
An empty string pattern is a mistake - there is no reason to do that. It can however happen (for instance when you generate the config file).

Before this fix, Karma would try to watch this empty string pattern, which would result in watching the entire `basePath` directory.

Now, the pattern will be ignored and a warning showed.
  • Loading branch information
vojtajina committed Nov 30, 2013
1 parent 6a02056 commit cd04594
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/config.js
Expand Up @@ -23,18 +23,19 @@ var UrlPattern = function(url) {


var createPatternObject = function(pattern) {
if (helper.isString(pattern)) {
if (pattern && helper.isString(pattern)) {
return helper.isUrlAbsolute(pattern) ? new UrlPattern(pattern) : new Pattern(pattern);
}

if (helper.isObject(pattern)) {
if (!helper.isDefined(pattern.pattern)) {
log.warn('Invalid pattern %s!\n\tObject is missing "pattern" property".', pattern);
}

return helper.isUrlAbsolute(pattern.pattern) ?
if (pattern.pattern && helper.isString(pattern.pattern)) {
return helper.isUrlAbsolute(pattern.pattern) ?
new UrlPattern(pattern.pattern) :
new Pattern(pattern.pattern, pattern.served, pattern.included, pattern.watched);
}

log.warn('Invalid pattern %s!\n\tObject is missing "pattern" property.', pattern);
return new Pattern(null, false, false, false);
}

log.warn('Invalid pattern %s!\n\tExpected string or object with "pattern" property.', pattern);
Expand Down

0 comments on commit cd04594

Please sign in to comment.