Skip to content

Commit 9f057f7

Browse files
committed
Revert "[Static Web Assets] Allow assets with empty base paths (#17414)"
This reverts commit b4d2f9a.
1 parent 8857906 commit 9f057f7

File tree

2 files changed

+0
-39
lines changed

2 files changed

+0
-39
lines changed

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ public IDirectoryContents GetDirectoryContents(string subpath)
4646
{
4747
var modifiedSub = NormalizePath(subpath);
4848

49-
if (BasePath == "/")
50-
{
51-
return InnerProvider.GetDirectoryContents(modifiedSub);
52-
}
53-
5449
if (StartsWithBasePath(modifiedSub, out var physicalPath))
5550
{
5651
return InnerProvider.GetDirectoryContents(physicalPath.Value);
@@ -72,11 +67,6 @@ public IFileInfo GetFileInfo(string subpath)
7267
{
7368
var modifiedSub = NormalizePath(subpath);
7469

75-
if (BasePath == "/")
76-
{
77-
return InnerProvider.GetFileInfo(subpath);
78-
}
79-
8070
if (!StartsWithBasePath(modifiedSub, out var physicalPath))
8171
{
8272
return new NotFoundFileInfo(subpath);

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

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -117,35 +117,6 @@ public void StaticWebAssetsFileProvider_FindsFileWithSpaces()
117117
Assert.True(provider.GetFileInfo("/_content/Static Web Assets.txt").Exists);
118118
}
119119

120-
[Fact]
121-
public void GetDirectoryContents_HandlesEmptyBasePath()
122-
{
123-
// Arrange
124-
var provider = new StaticWebAssetsFileProvider("/",
125-
Path.Combine(AppContext.BaseDirectory, "testroot", "wwwroot"));
126-
127-
// Act
128-
var directory = provider.GetDirectoryContents("/Static Web/");
129-
130-
// Assert
131-
Assert.Collection(directory,
132-
file =>
133-
{
134-
Assert.Equal("Static Web.txt", file.Name);
135-
});
136-
}
137-
138-
[Fact]
139-
public void StaticWebAssetsFileProviderWithEmptyBasePath_FindsFile()
140-
{
141-
// Arrange & Act
142-
var provider = new StaticWebAssetsFileProvider("/",
143-
Path.Combine(AppContext.BaseDirectory, "testroot", "wwwroot"));
144-
145-
// Assert
146-
Assert.True(provider.GetFileInfo("/Static Web Assets.txt").Exists);
147-
}
148-
149120
[Fact]
150121
public void GetFileInfo_DoesNotMatch_IncompletePrefixSegments()
151122
{

0 commit comments

Comments
 (0)