Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Empty glob pattern incorrectly expands to "/**" #11476

Merged
merged 2 commits into from Mar 15, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/util/glob-utils.js
Expand Up @@ -166,7 +166,9 @@ function resolveFileGlobPatterns(patterns, options) {

const processPathExtensions = processPath(options);

return patterns.map(processPathExtensions);
return patterns
.filter(pattern => pattern.length > 0)
.map(processPathExtensions);
}

const dotfilesPattern = /(?:(?:^\.)|(?:[/\\]\.))[^/\\.].*/u;
Expand Down
10 changes: 10 additions & 0 deletions tests/lib/util/glob-utils.js
Expand Up @@ -69,6 +69,16 @@ describe("globUtils", () => {
assert.deepStrictEqual(result, ["one-js-file"]);
});

it("should not convert empty path string to a glob pattern", () => {
const patterns = [""];
const opts = {
cwd: getFixturePath("glob-util")
};
const result = globUtils.resolveFileGlobPatterns(patterns, opts);

assert.deepStrictEqual(result, []);
});

it("should convert an absolute directory name with no provided extensions into a posix glob pattern", () => {
const patterns = [getFixturePath("glob-util", "one-js-file")];
const opts = {
Expand Down