Skip to content

Commit 867bbf3

Browse files
committed
Fix bug
1 parent 1793bfc commit 867bbf3

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/StaticWebAssetsSdk/Tasks/Utils/Globbing/StaticWebAssetGlobMatcher.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,10 @@ private static MatchStage GetInitialStage(GlobNode node)
479479
return MatchStage.Done;
480480
}
481481

482-
internal readonly MatchState NextExtension(int extensionIndex) => new(Node, MatchStage.Extension, SegmentIndex, extensionIndex, ComplexSegmentIndex);
482+
internal readonly MatchState NextExtension(int extensionIndex) => new(Node, MatchStage.Extension, SegmentIndex, extensionIndex, ComplexSegmentIndex)
483+
{
484+
StemStartIndex = StemStartIndex
485+
};
483486

484487
internal readonly MatchState NextComplex() => new(Node, MatchStage.Complex, SegmentIndex, ExtensionSegmentIndex, ComplexSegmentIndex + 1);
485488

test/Microsoft.NET.Sdk.StaticWebAssets.Tests/StaticWebAssets/Globbing/StaticWebAssetGlobMatcherTest.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,29 @@ namespace Microsoft.AspNetCore.StaticWebAssets.Tasks.Test;
2727
// Recursive wildcard in the middle 'a/**/c'
2828
public partial class StaticWebAssetGlobMatcherTest
2929
{
30+
[Theory]
31+
[InlineData("**/*.razor.js", "Components/Pages/RegularComponent.razor.js", "Components/Pages/RegularComponent.razor.js")]
32+
[InlineData("**/*.razor.js", "Components/User.Profile.Details.razor.js", "Components/User.Profile.Details.razor.js")]
33+
[InlineData("**/*.razor.js", "Components/Area/Sub/Feature/User.Profile.Details.razor.js", "Components/Area/Sub/Feature/User.Profile.Details.razor.js")]
34+
[InlineData("**/*.razor.js", "Components/Area/Sub/Feature/Deep.Component.Name.With.Many.Parts.razor.js", "Components/Area/Sub/Feature/Deep.Component.Name.With.Many.Parts.razor.js")]
35+
[InlineData("**/*.cshtml.js", "Pages/Shared/_Host.cshtml.js", "Pages/Shared/_Host.cshtml.js")]
36+
[InlineData("**/*.cshtml.js", "Areas/Admin/Pages/Dashboard.cshtml.js", "Areas/Admin/Pages/Dashboard.cshtml.js")]
37+
[InlineData("*.lib.module.js", "Widget.lib.module.js", "Widget.lib.module.js")]
38+
[InlineData("*.razor.css", "Component.razor.css", "Component.razor.css")]
39+
[InlineData("*.cshtml.css", "View.cshtml.css", "View.cshtml.css")]
40+
[InlineData("*.modules.json", "app.modules.json", "app.modules.json")]
41+
[InlineData("*.lib.module.js", "Rcl.Client.Feature.lib.module.js", "Rcl.Client.Feature.lib.module.js")]
42+
public void Can_Match_WellKnownExistingPatterns(string pattern, string path, string expectedStem)
43+
{
44+
var matcher = new StaticWebAssetGlobMatcherBuilder();
45+
matcher.AddIncludePatterns(pattern);
46+
var globMatcher = matcher.Build();
47+
48+
var match = globMatcher.Match(path);
49+
Assert.True(match.IsMatch);
50+
Assert.Equal(pattern, match.Pattern);
51+
Assert.Equal(expectedStem, match.Stem);
52+
}
3053
[Fact]
3154
public void CanMatchLiterals()
3255
{

0 commit comments

Comments
 (0)