Make encoders registration optional (#140)
This commit is contained in:
parent
e28e1df605
commit
c310c27ab8
|
|
@ -24,6 +24,17 @@ namespace Microsoft.AspNetCore.StaticFiles
|
||||||
private readonly IDirectoryFormatter _formatter;
|
private readonly IDirectoryFormatter _formatter;
|
||||||
private readonly IFileProvider _fileProvider;
|
private readonly IFileProvider _fileProvider;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new instance of the SendFileMiddleware. Using <see cref="HtmlEncoder.Default"/> instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="next">The next middleware in the pipeline.</param>
|
||||||
|
/// <param name="hostingEnv">The <see cref="IHostingEnvironment"/> used by this middleware.</param>
|
||||||
|
/// <param name="options">The configuration for this middleware.</param>
|
||||||
|
public DirectoryBrowserMiddleware(RequestDelegate next, IHostingEnvironment hostingEnv, IOptions<DirectoryBrowserOptions> options)
|
||||||
|
: this(next, hostingEnv, HtmlEncoder.Default, options)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new instance of the SendFileMiddleware.
|
/// Creates a new instance of the SendFileMiddleware.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,14 @@ namespace Microsoft.AspNetCore.StaticFiles
|
||||||
{
|
{
|
||||||
public class DirectoryBrowserMiddlewareTests
|
public class DirectoryBrowserMiddlewareTests
|
||||||
{
|
{
|
||||||
|
[Fact]
|
||||||
|
public void WorksWithoutEncoderRegistered()
|
||||||
|
{
|
||||||
|
// No exception, uses HtmlEncoder.Default
|
||||||
|
StaticFilesTestServer.Create(
|
||||||
|
app => app.UseDirectoryBrowser());
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task NullArguments()
|
public async Task NullArguments()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue