Update `StaticWebAssetsFileProvider NormalizePath` (#22418)
Skips an unnecessary null check.
This commit is contained in:
parent
2e7359d8d3
commit
37a4457150
|
|
@ -96,7 +96,7 @@ namespace Microsoft.AspNetCore.Hosting.StaticWebAssets
|
||||||
private static string NormalizePath(string path)
|
private static string NormalizePath(string path)
|
||||||
{
|
{
|
||||||
path = path.Replace('\\', '/');
|
path = path.Replace('\\', '/');
|
||||||
return path != null && path.StartsWith("/") ? path : "/" + path;
|
return path.StartsWith("/") ? path : "/" + path;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool StartsWithBasePath(string subpath, out PathString rest)
|
private bool StartsWithBasePath(string subpath, out PathString rest)
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,20 @@ namespace Microsoft.AspNetCore.Hosting.StaticWebAssets
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Empty(directory);
|
Assert.Empty(directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void GetDirectoryContents_HandlersEmptyPath()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var provider = new StaticWebAssetsFileProvider("/_content",
|
||||||
|
Path.Combine(AppContext.BaseDirectory, "testroot", "wwwroot"));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var directory = provider.GetDirectoryContents("");
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.True(directory.Exists);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void GetDirectoryContents_HandlesWhitespaceInBase()
|
public void GetDirectoryContents_HandlesWhitespaceInBase()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue