提交 6e366f56 编写于 作者: B Benjamin Pasero

Glob regex matches too much (fixes #6936)

上级 422e34bc
......@@ -18,8 +18,6 @@ export interface SiblingClause {
const PATH_REGEX = '[/\\\\]'; // any slash or backslash
const NO_PATH_REGEX = '[^/\\\\]'; // any non-slash and non-backslash
const BEGINS_WITH_PATH_REGEX = `${PATH_REGEX}.*?`; // anything that begins with a path or just the path itself
const ENDS_WITH_PATH_REGEX = `.+?${PATH_REGEX}`;
function starsToRegExp(starCount: number): string {
switch (starCount) {
......@@ -31,7 +29,7 @@ function starsToRegExp(starCount: number): string {
// Matches: (Path Sep OR Path Val followed by Path Sep OR Path Sep followed by Path Val) 0-many times
// Group is non capturing because we don't need to capture at all (?:...)
// Overall we use non-greedy matching because it could be that we match too much
return `(?:${BEGINS_WITH_PATH_REGEX}|${ENDS_WITH_PATH_REGEX}|)`;
return `(?:${PATH_REGEX}|${NO_PATH_REGEX}+${PATH_REGEX}|${PATH_REGEX}${NO_PATH_REGEX}+)*?`;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册