Skip to content

Commit 579f30f

Browse files
authored
[Blazor][Fixes #14999] Razor Class Library Static Assets with spaces do not resolve (#15024)
1 parent 0dad6fe commit 579f30f

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

src/Hosting/Hosting/src/StaticWebAssets/StaticWebAssetsFileProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public IDirectoryContents GetDirectoryContents(string subpath)
4646
}
4747
else
4848
{
49-
return InnerProvider.GetDirectoryContents(physicalPath);
49+
return InnerProvider.GetDirectoryContents(physicalPath.Value);
5050
}
5151
}
5252

@@ -59,7 +59,7 @@ public IFileInfo GetFileInfo(string subpath)
5959
}
6060
else
6161
{
62-
return InnerProvider.GetFileInfo(physicalPath);
62+
return InnerProvider.GetFileInfo(physicalPath.Value);
6363
}
6464
}
6565

src/Hosting/Hosting/test/Microsoft.AspNetCore.Hosting.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<Compile Include="$(SharedSourceRoot)EventSource.Testing\TestEventListener.cs" />
1010
<Compile Include="$(SharedSourceRoot)EventSource.Testing\TestCounterListener.cs" />
1111
<Content Include="testroot\**\*" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" />
12+
<None Remove="testroot\wwwroot\Static Web Assets.txt" />
1213
<Content Include="Microsoft.AspNetCore.Hosting.StaticWebAssets.xml" CopyToOutputDirectory="PreserveNewest" />
1314
</ItemGroup>
1415

src/Hosting/Hosting/test/StaticWebAssets/StaticWebAssetsFileProviderTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ public void StaticWebAssetsFileProvider_Constructor_DoesNotPrependPrefixWithSlas
3737
Assert.Equal("/_content", provider.BasePath);
3838
}
3939

40+
[Fact]
41+
public void StaticWebAssetsFileProvider_FindsFileWithSpaces()
42+
{
43+
// Arrange & Act
44+
var provider = new StaticWebAssetsFileProvider("/_content",
45+
Path.Combine(AppContext.BaseDirectory, "testroot", "wwwroot"));
46+
47+
// Assert
48+
Assert.True(provider.GetFileInfo("/_content/Static Web Assets.txt").Exists);
49+
}
50+
4051
[Fact]
4152
public void GetFileInfo_DoesNotMatch_IncompletePrefixSegments()
4253
{
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This file is here to validate that the static web assets file provider respect spaces.

0 commit comments

Comments
 (0)