3
3
4
4
#nullable disable
5
5
6
+ using System . Text . Json ;
6
7
using System . Text . RegularExpressions ;
7
8
using Microsoft . AspNetCore . StaticWebAssets . Tasks ;
8
9
@@ -625,12 +626,12 @@ public void Build_GeneratesUrlEncodedLinkHeaderForNonAsciiProjectName()
625
626
ProjectDirectory = CreateAspNetSdkTestAsset ( testAsset ) ;
626
627
627
628
// Rename the ClassLibrary project to have non-ASCII characters
628
- var originalLibPath = Path . Combine ( ProjectDirectory . Path , "ClassLibrary " ) ;
629
+ var originalLibPath = Path . Combine ( ProjectDirectory . Path , "AnotherClassLib " ) ;
629
630
var newLibPath = Path . Combine ( ProjectDirectory . Path , "项目" ) ;
630
631
Directory . Move ( originalLibPath , newLibPath ) ;
631
632
632
633
// Update the project file to set the assembly name and package ID
633
- var libProjectFile = Path . Combine ( newLibPath , "ClassLibrary .csproj" ) ;
634
+ var libProjectFile = Path . Combine ( newLibPath , "AnotherClassLib .csproj" ) ;
634
635
var newLibProjectFile = Path . Combine ( newLibPath , "项目.csproj" ) ;
635
636
File . Move ( libProjectFile , newLibProjectFile ) ;
636
637
@@ -649,11 +650,11 @@ public void Build_GeneratesUrlEncodedLinkHeaderForNonAsciiProjectName()
649
650
// Update the main project to reference the renamed library
650
651
var mainProjectFile = Path . Combine ( ProjectDirectory . Path , "AppWithPackageAndP2PReference" , "AppWithPackageAndP2PReference.csproj" ) ;
651
652
var mainProjectContent = File . ReadAllText ( mainProjectFile ) ;
652
- mainProjectContent = mainProjectContent . Replace ( @"..\ClassLibrary\ClassLibrary .csproj" , @"..\项目\项目.csproj" ) ;
653
+ mainProjectContent = mainProjectContent . Replace ( @"..\AnotherClassLib\AnotherClassLib .csproj" , @"..\项目\项目.csproj" ) ;
653
654
File . WriteAllText ( mainProjectFile , mainProjectContent ) ;
654
655
655
656
// Ensure library has scoped CSS
656
- var libCssFile = Path . Combine ( newLibPath , "Components " , "Component1.razor .css" ) ;
657
+ var libCssFile = Path . Combine ( newLibPath , "Views " , "Shared" , "Index.cshtml .css") ;
657
658
if ( ! File . Exists ( libCssFile ) )
658
659
{
659
660
Directory . CreateDirectory ( Path . GetDirectoryName ( libCssFile ) ) ;
@@ -675,9 +676,14 @@ public void Build_GeneratesUrlEncodedLinkHeaderForNonAsciiProjectName()
675
676
new FileInfo ( endpointsFile ) . Should ( ) . Exist ( ) ;
676
677
677
678
var endpointsContent = File . ReadAllText ( endpointsFile ) ;
679
+ var json = JsonSerializer . Deserialize < StaticWebAssetEndpointsManifest > ( endpointsContent , new JsonSerializerOptions ( JsonSerializerDefaults . Web ) ) ;
678
680
679
- // Verify that the Link header contains URL-encoded characters (%E9%A1%B9%E7%9B%AE is "项目" encoded)
680
- endpointsContent . Should ( ) . Contain ( "%E9%A1%B9%E7%9B%AE" ) ;
681
+ var styles = json . Endpoints . Where ( e => e . Route . EndsWith ( "styles.css" ) ) ;
682
+
683
+ foreach ( var styleEndpoint in styles )
684
+ {
685
+ styleEndpoint . ResponseHeaders . Should ( ) . Contain ( h => h . Name . Equals ( "Link" , StringComparison . OrdinalIgnoreCase ) && h . Value . Contains ( "%E9%A1%B9%E7%9B%AE" ) ) ;
686
+ }
681
687
}
682
688
}
683
689
}
0 commit comments