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 issue with MiddleSlash replacer #17

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix issue with MiddleSlash replacer
  • Loading branch information
jairbubbles committed Mar 2, 2021
commit f303e6cffb3abd3b7c23eaa2015dab436b125544
2 changes: 1 addition & 1 deletion src/Ignore.Tests/GitBasedTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void TrailingStar() => GitBasedTest(
@"""
foo*
""",
new[] { "fooc", "foo/bar/foo", "foo/foob.cs", "foo/bar/bar.csproj" });
new[] { "fooc", "foo/bar/foo", "foo/foob.cs", "foo/bar/bar.csproj", "bar/foo" });

[Fact]
public void EscapedBang() => GitBasedTest(
Expand Down
3 changes: 3 additions & 0 deletions src/Ignore.Tests/ReplacerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class ReplacerTests
new object[] { ReplacerStash.Metacharacters, @"a $ . | * + ( ) { ^ b", @"a \$ \. \| \* \+ \( \) \{ \^ b" },
new object[] { ReplacerStash.QuestionMark, @"a?", @"a[^/]" },
new object[] { ReplacerStash.LeadingSlash, @"/a/b", @"^a/b" },
new object[] { ReplacerStash.LeadingSlash, @"a/b", @"a/b" },
new object[] { ReplacerStash.MetacharacterSlashAfterLeadingSlash, @"a/b", @"a\/b" },
new object[] { ReplacerStash.LeadingDoubleStar, @"**/a/b", @".*a/b" },
new object[] { ReplacerStash.MiddleDoubleStar, @"**/a/b", @"**/a/b" },
Expand All @@ -29,6 +30,8 @@ public class ReplacerTests
new object[] { ReplacerStash.MiddleSlash, @"a/b/c/d", @"^a/b/c/d" },
new object[] { ReplacerStash.MiddleSlash, @"a/", @"a/" },
new object[] { ReplacerStash.MiddleSlash, @"/a/", @"/a/" },
new object[] { ReplacerStash.MiddleSlash, @"foo*", @"foo*" },
new object[] { ReplacerStash.MiddleSlash, @"foo[^/]*", @"foo[^/]*" },
new object[] { ReplacerStash.TrailingSlash, @"/a/", @"/a/$" },
new object[] { ReplacerStash.NoTrailingSlash, @"/a/", @"/a/" },
new object[] { ReplacerStash.NoTrailingSlash, @"/a", @"/a(/.*)?$" },
Expand Down
2 changes: 1 addition & 1 deletion src/Ignore/ReplacerStash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static class ReplacerStash
/// </summary>
public static readonly Replacer MiddleSlash = new Replacer(
name: nameof(MiddleSlash),
regex: new Regex(@"^([^/]+/[^/]+)"),
regex: new Regex(@"^([^/\^]+/[^/]+)"),
replacer: match => $"^{match.Groups[1]}");

/// <summary>
Expand Down