Skip to content

Commit dec378b

Browse files
Copilotjaviercn
andcommitted
Final verification that URL encoding fix works correctly
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
1 parent 0e1881a commit dec378b

21 files changed

+87
-81
lines changed

test/Microsoft.NET.Sdk.StaticWebAssets.Tests/ComputeStaticWebAssetsTargetPathsTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using Moq;
1414

1515
namespace Microsoft.NET.Sdk.StaticWebAssets.Tests;
16+
1617
public class ComputeStaticWebAssetsTargetPathsTest
1718
{
1819
[Fact]

test/Microsoft.NET.Sdk.StaticWebAssets.Tests/JsModulesIntegrationTest.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ public void Build_GeneratesManifestWhenItFindsALibrary()
3131
{
3232
var testAsset = "RazorComponentApp";
3333
var projectDirectory = CreateAspNetSdkTestAsset(testAsset)
34-
.WithProjectChanges(p => {
35-
var fingerprintContent = p.Descendants()
36-
.SingleOrDefault(e => e.Name.LocalName == "StaticWebAssetsFingerprintContent");
37-
fingerprintContent.Value = "true";
38-
});
34+
.WithProjectChanges(p =>
35+
{
36+
var fingerprintContent = p.Descendants()
37+
.SingleOrDefault(e => e.Name.LocalName == "StaticWebAssetsFingerprintContent");
38+
fingerprintContent.Value = "true";
39+
});
3940

4041
Directory.CreateDirectory(Path.Combine(projectDirectory.TestRoot, "wwwroot"));
4142
File.WriteAllText(Path.Combine(projectDirectory.TestRoot, "wwwroot", "ComponentApp.lib.module.js"), "console.log('Hello world!');");
@@ -89,7 +90,8 @@ public void Publish_PublishesJsModuleBundleBundleToTheRightLocation()
8990
{
9091
var testAsset = "RazorComponentApp";
9192
ProjectDirectory = CreateAspNetSdkTestAsset(testAsset)
92-
.WithProjectChanges(p => {
93+
.WithProjectChanges(p =>
94+
{
9395
var fingerprintContent = p.Descendants()
9496
.SingleOrDefault(e => e.Name.LocalName == "StaticWebAssetsFingerprintContent");
9597
fingerprintContent.Value = "true";

test/Microsoft.NET.Sdk.StaticWebAssets.Tests/LegacyStaticWebAssetsV1IntegrationTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
using Microsoft.AspNetCore.StaticWebAssets.Tasks;
55

6-
[assembly:CollectionBehavior(DisableTestParallelization = true)]
6+
[assembly: CollectionBehavior(DisableTestParallelization = true)]
77

88
namespace Microsoft.NET.Sdk.StaticWebAssets.Tests
99
{

test/Microsoft.NET.Sdk.StaticWebAssets.Tests/ScopedCssIntegrationTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -634,16 +634,16 @@ public void Build_GeneratesUrlEncodedLinkHeaderForNonAsciiProjectName()
634634
ExecuteCommand(build, "/p:PackageId=项目").Should().Pass();
635635

636636
var intermediateOutputPath = build.GetIntermediateDirectory(DefaultTfm, "Debug").ToString();
637-
637+
638638
// Check that the staticwebassets.build.endpoints.json file contains URL-encoded characters
639639
var endpointsFile = Path.Combine(intermediateOutputPath, "staticwebassets.build.endpoints.json");
640640
new FileInfo(endpointsFile).Should().Exist();
641-
641+
642642
var endpointsContent = File.ReadAllText(endpointsFile);
643-
643+
644644
// Verify that the Link header contains URL-encoded characters (%E9%A1%B9%E7%9B%AE is "项目" encoded)
645645
endpointsContent.Should().Contain("%E9%A1%B9%E7%9B%AE");
646-
646+
647647
// Verify it doesn't contain the unencoded characters
648648
endpointsContent.Should().NotContain("项目");
649649
}

test/Microsoft.NET.Sdk.StaticWebAssets.Tests/StaticWebAssetEndpointsIntegrationTest.cs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ private bool MatchUncompresedProjectBundlesNoFingerprint(StaticWebAssetEndpoint
8585
Success: true,
8686
Groups: [
8787
var _,
88-
{ Name: "project", Value: "ComponentApp", Success: true, },
89-
{ Name: "fingerprint", Value: "", Success: false },
90-
{ Name: "compress", Value: "", Success: false }
88+
{ Name: "project", Value: "ComponentApp", Success: true, },
89+
{ Name: "fingerprint", Value: "", Success: false },
90+
{ Name: "compress", Value: "", Success: false }
9191
]
9292
};
9393

@@ -96,9 +96,9 @@ private bool MatchCompressedProjectBundlesNoFingerprint(StaticWebAssetEndpoint e
9696
Success: true,
9797
Groups: [
9898
var _,
99-
{ Name: "project", Value: "ComponentApp", Success: true, },
100-
{ Name: "fingerprint", Value: "", Success: false },
101-
{ Name: "compress", Value: var compress, Success: true }
99+
{ Name: "project", Value: "ComponentApp", Success: true, },
100+
{ Name: "fingerprint", Value: "", Success: false },
101+
{ Name: "compress", Value: var compress, Success: true }
102102
]
103103
} && (compress == ".gz" || compress == ".br");
104104

@@ -107,9 +107,9 @@ private bool MatchUncompressedProjectBundlesWithFingerprint(StaticWebAssetEndpoi
107107
Success: true,
108108
Groups: [
109109
var m,
110-
{ Name: "project", Value: "ComponentApp", Success: true, },
111-
{ Name: "fingerprint", Value: var fingerprint, Success: true },
112-
{ Name: "compress", Value: "", Success: false }
110+
{ Name: "project", Value: "ComponentApp", Success: true, },
111+
{ Name: "fingerprint", Value: var fingerprint, Success: true },
112+
{ Name: "compress", Value: "", Success: false }
113113
]
114114
} && fingerprint == ep.EndpointProperties.Single(p => p.Name == "fingerprint").Value;
115115

@@ -118,9 +118,9 @@ private bool MatchCompressedProjectBundlesWithFingerprint(StaticWebAssetEndpoint
118118
Success: true,
119119
Groups: [
120120
var m,
121-
{ Name: "project", Value: "ComponentApp", Success: true, },
122-
{ Name: "fingerprint", Value: var fingerprint, Success: true },
123-
{ Name: "compress", Value: var compress, Success: true }
121+
{ Name: "project", Value: "ComponentApp", Success: true, },
122+
{ Name: "fingerprint", Value: var fingerprint, Success: true },
123+
{ Name: "compress", Value: var compress, Success: true }
124124
]
125125
} && !string.IsNullOrWhiteSpace(fingerprint)
126126
&& (compress == ".gz" || compress == ".br");
@@ -130,9 +130,9 @@ private bool MatchUncompressedAppBundleNoFingerprint(StaticWebAssetEndpoint ep)
130130
Success: true,
131131
Groups: [
132132
var _,
133-
{ Name: "project", Value: "ComponentApp", Success: true, },
134-
{ Name: "fingerprint", Value: "", Success: false },
135-
{ Name: "compress", Value: "", Success: false }
133+
{ Name: "project", Value: "ComponentApp", Success: true, },
134+
{ Name: "fingerprint", Value: "", Success: false },
135+
{ Name: "compress", Value: "", Success: false }
136136
]
137137
};
138138

@@ -141,9 +141,9 @@ private bool MatchCompressedAppBundleNoFingerprint(StaticWebAssetEndpoint ep) =>
141141
Success: true,
142142
Groups: [
143143
var _,
144-
{ Name: "project", Value: "ComponentApp", Success: true, },
145-
{ Name: "fingerprint", Value: "", Success: false },
146-
{ Name: "compress", Value: var compress, Success: true }
144+
{ Name: "project", Value: "ComponentApp", Success: true, },
145+
{ Name: "fingerprint", Value: "", Success: false },
146+
{ Name: "compress", Value: var compress, Success: true }
147147
]
148148
} && (compress == ".gz" || compress == ".br");
149149

@@ -152,9 +152,9 @@ private bool MatchUncompressedAppBundleWithFingerprint(StaticWebAssetEndpoint ep
152152
Success: true,
153153
Groups: [
154154
var m,
155-
{ Name: "project", Value: "ComponentApp", Success: true, },
156-
{ Name: "fingerprint", Value: var fingerprint, Success: true },
157-
{ Name: "compress", Value: "", Success: false }
155+
{ Name: "project", Value: "ComponentApp", Success: true, },
156+
{ Name: "fingerprint", Value: var fingerprint, Success: true },
157+
{ Name: "compress", Value: "", Success: false }
158158
]
159159
} && fingerprint == ep.EndpointProperties.Single(p => p.Name == "fingerprint").Value;
160160

@@ -163,9 +163,9 @@ private bool MatchCompressedAppBundleWithFingerprint(StaticWebAssetEndpoint ep)
163163
Success: true,
164164
Groups: [
165165
var m,
166-
{ Name: "project", Value: "ComponentApp", Success: true, },
167-
{ Name: "fingerprint", Value: var fingerprint, Success: true },
168-
{ Name: "compress", Value: var compress, Success: true }
166+
{ Name: "project", Value: "ComponentApp", Success: true, },
167+
{ Name: "fingerprint", Value: var fingerprint, Success: true },
168+
{ Name: "compress", Value: var compress, Success: true }
169169
]
170170
} && !string.IsNullOrWhiteSpace(fingerprint)
171171
&& (compress == ".gz" || compress == ".br");

test/Microsoft.NET.Sdk.StaticWebAssets.Tests/StaticWebAssets/DefineStaticWebAssetEndpointsTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33

44
#nullable disable
55

6-
using System.Diagnostics.Metrics;
76
using System.Diagnostics;
7+
using System.Diagnostics.Metrics;
8+
using System.Globalization;
9+
using System.Net;
810
using Microsoft.AspNetCore.StaticWebAssets.Tasks;
911
using Microsoft.Build.Framework;
1012
using Microsoft.Build.Utilities;
1113
using Moq;
1214
using NuGet.Packaging.Core;
13-
using System.Net;
14-
using System.Globalization;
1515

1616
namespace Microsoft.NET.Sdk.StaticWebAssets.Tests;
1717

test/Microsoft.NET.Sdk.StaticWebAssets.Tests/StaticWebAssets/DiscoverPrecompressedAssetsTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void DiscoversPrecompressedAssetsCorrectly()
4444
CopyToOutputDirectory = StaticWebAsset.AssetCopyOptions.Never,
4545
Fingerprint = "uncompressed",
4646
RelatedAsset = string.Empty,
47-
ContentRoot = Path.Combine(Environment.CurrentDirectory,"wwwroot"),
47+
ContentRoot = Path.Combine(Environment.CurrentDirectory, "wwwroot"),
4848
SourceType = StaticWebAsset.SourceTypes.Discovered,
4949
Integrity = "uncompressed-integrity",
5050
AssetRole = StaticWebAsset.AssetRoles.Primary,

test/Microsoft.NET.Sdk.StaticWebAssets.Tests/StaticWebAssets/DiscoverStaticWebAssetsTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ public void FingerprintsContentUsingPatternsWhenMoreThanOneExtension(string file
217217
asset.GetMetadata(nameof(StaticWebAsset.OriginalItemSpec)).Should().Be(Path.Combine("wwwroot", fileName));
218218
}
219219

220-
[Fact]
221-
[Trait("Category", "FingerprintIdentity")]
222-
public void ComputesIdentity_UsingFingerprintPattern_ForComputedAssets_WhenIdentityNeedsComputation()
220+
[Fact]
221+
[Trait("Category", "FingerprintIdentity")]
222+
public void ComputesIdentity_UsingFingerprintPattern_ForComputedAssets_WhenIdentityNeedsComputation()
223223
{
224224
// Arrange: simulate a packaged asset (outside content root) with a RelativePath inside the app
225225
var errorMessages = new List<string>();
@@ -251,7 +251,7 @@ public void ComputesIdentity_UsingFingerprintPattern_ForComputedAssets_WhenIdent
251251
})
252252
],
253253
// No RelativePathPattern, we trigger the branch that synthesizes identity under content root.
254-
FingerprintPatterns = [ new TaskItem("Js", new Dictionary<string,string>{{"Pattern","*.js"},{"Expression","#[.{fingerprint}]!"}})],
254+
FingerprintPatterns = [new TaskItem("Js", new Dictionary<string, string> { { "Pattern", "*.js" }, { "Expression", "#[.{fingerprint}]!" } })],
255255
FingerprintCandidates = true,
256256
SourceType = "Computed",
257257
SourceId = "Client",

test/Microsoft.NET.Sdk.StaticWebAssets.Tests/StaticWebAssets/FilterStaticWebAssetEndpointsTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Moq;
1010

1111
namespace Microsoft.NET.Sdk.StaticWebAssets.Tests.StaticWebAssets;
12+
1213
public class FilterStaticWebAssetEndpointsTest
1314
{
1415
[Fact]

test/Microsoft.NET.Sdk.StaticWebAssets.Tests/StaticWebAssets/GenerateStaticWebAssetEndpointsManifestTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,11 @@ public void ExcludesEndpoints_BasedOnExclusionPatterns()
253253
// Assert
254254
new FileInfo(path).Should().Exist();
255255
new FileInfo(exclusionCachePath).Should().Exist();
256-
256+
257257
var manifest = File.ReadAllText(path);
258258
var json = JsonSerializer.Deserialize<StaticWebAssetEndpointsManifest>(manifest);
259259
json.Should().NotBeNull();
260-
260+
261261
// Only styles.css endpoint should remain as others match _content/MyApp/**
262262
json.Endpoints.Should().HaveCount(1);
263263
json.Endpoints[0].Route.Should().Contain("styles.css");
@@ -406,7 +406,7 @@ public void RegeneratesManifest_WhenExclusionPatternsChange()
406406
// Assert - File should be regenerated
407407
var secondWriteTime = File.GetLastWriteTimeUtc(endpointsManifestPath);
408408
secondWriteTime.Should().BeAfter(firstWriteTime);
409-
409+
410410
// Verify cache file was updated
411411
var cacheContent = File.ReadAllText(exclusionCachePath);
412412
cacheContent.Should().Contain("different/**");

0 commit comments

Comments
 (0)