Skip to content
This repository was archived by the owner on Nov 22, 2018. It is now read-only.

Commit c310c27

Browse files
authored
Make encoders registration optional (#140)
1 parent e28e1df commit c310c27

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/Microsoft.AspNetCore.StaticFiles/DirectoryBrowserMiddleware.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ public class DirectoryBrowserMiddleware
2424
private readonly IDirectoryFormatter _formatter;
2525
private readonly IFileProvider _fileProvider;
2626

27+
/// <summary>
28+
/// Creates a new instance of the SendFileMiddleware. Using <see cref="HtmlEncoder.Default"/> instance.
29+
/// </summary>
30+
/// <param name="next">The next middleware in the pipeline.</param>
31+
/// <param name="hostingEnv">The <see cref="IHostingEnvironment"/> used by this middleware.</param>
32+
/// <param name="options">The configuration for this middleware.</param>
33+
public DirectoryBrowserMiddleware(RequestDelegate next, IHostingEnvironment hostingEnv, IOptions<DirectoryBrowserOptions> options)
34+
: this(next, hostingEnv, HtmlEncoder.Default, options)
35+
{
36+
}
37+
2738
/// <summary>
2839
/// Creates a new instance of the SendFileMiddleware.
2940
/// </summary>

test/Microsoft.AspNetCore.StaticFiles.Tests/DirectoryBrowserMiddlewareTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ namespace Microsoft.AspNetCore.StaticFiles
1919
{
2020
public class DirectoryBrowserMiddlewareTests
2121
{
22+
[Fact]
23+
public void WorksWithoutEncoderRegistered()
24+
{
25+
// No exception, uses HtmlEncoder.Default
26+
StaticFilesTestServer.Create(
27+
app => app.UseDirectoryBrowser());
28+
}
29+
2230
[Fact]
2331
public async Task NullArguments()
2432
{

0 commit comments

Comments
 (0)