Skip to content

[Blazor][Fixes #14999] Razor Class Library Static Assets with spaces do not resolve #15024

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

Merged
merged 1 commit into from
Oct 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public IDirectoryContents GetDirectoryContents(string subpath)
}
else
{
return InnerProvider.GetDirectoryContents(physicalPath);
return InnerProvider.GetDirectoryContents(physicalPath.Value);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was being implicitly converted to "string" and that would encode spaces as "%20". The fix simply passes down the raw value (which was already decoded by hosting) to the underlying provider

}
}

Expand All @@ -59,7 +59,7 @@ public IFileInfo GetFileInfo(string subpath)
}
else
{
return InnerProvider.GetFileInfo(physicalPath);
return InnerProvider.GetFileInfo(physicalPath.Value);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<Compile Include="$(SharedSourceRoot)EventSource.Testing\TestEventListener.cs" />
<Compile Include="$(SharedSourceRoot)EventSource.Testing\TestCounterListener.cs" />
<Content Include="testroot\**\*" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" />
<None Remove="testroot\wwwroot\Static Web Assets.txt" />
<Content Include="Microsoft.AspNetCore.Hosting.StaticWebAssets.xml" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ public void StaticWebAssetsFileProvider_Constructor_DoesNotPrependPrefixWithSlas
Assert.Equal("/_content", provider.BasePath);
}

[Fact]
public void StaticWebAssetsFileProvider_FindsFileWithSpaces()
{
// Arrange & Act
var provider = new StaticWebAssetsFileProvider("/_content",
Path.Combine(AppContext.BaseDirectory, "testroot", "wwwroot"));

// Assert
Assert.True(provider.GetFileInfo("/_content/Static Web Assets.txt").Exists);
}

[Fact]
public void GetFileInfo_DoesNotMatch_IncompletePrefixSegments()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This file is here to validate that the static web assets file provider respect spaces.