-
Notifications
You must be signed in to change notification settings - Fork 5.5k
FileSystemGlobbing: Allow rootDir paths ending with separator to match files correctly #45139
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -119,13 +119,11 @@ public override IEnumerable<FileSystemInfoBase> EnumerateFileSystemInfos() | |
|
|
||
| private bool IsRootDirectory(string rootDir, string filePath) | ||
| { | ||
| if (!filePath.StartsWith(rootDir, StringComparison.Ordinal) || | ||
| filePath.IndexOf(Path.DirectorySeparatorChar, rootDir.Length) != rootDir.Length) | ||
| { | ||
| return false; | ||
| } | ||
| int rootDirLength = rootDir.Length; | ||
|
|
||
| return true; | ||
| return filePath.StartsWith(rootDir, StringComparison.Ordinal) && | ||
| (rootDir[rootDirLength - 1] == Path.DirectorySeparatorChar || | ||
| filePath.IndexOf(Path.DirectorySeparatorChar, rootDirLength) == rootDirLength); | ||
|
Comment on lines
125
to
126
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Existing condition on line 126 was meant to avoid false positives when the path started with However that same condition was interfering when Therefore I added condition on line 125 in order to skip the length check when rootDir ends with a separator.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems line 126 checks one char in position rootDirLength - why do we use whole IndexOf() method instead of simple index - filePath[rootDirLength] == Path.DirectorySeparatorChar - like in line 125? |
||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.