Skip to content

Commit adf3c1e

Browse files
committed
Add custom HtmlEncoder to DI
1 parent ac80de9 commit adf3c1e

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

src/BenchmarksApps/TechEmpower/BlazorSSR/Program.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
builder.Services.AddRazorComponents();
2626
builder.Services.AddSingleton(serviceProvider =>
2727
{
28-
// TODO: This custom configured HtmlEncoder won't actually be used until Blazor supports it: https://github.com/dotnet/aspnetcore/issues/47477
2928
var settings = new TextEncoderSettings(UnicodeRanges.BasicLatin, UnicodeRanges.Katakana, UnicodeRanges.Hiragana);
3029
settings.AllowCharacter('\u2014'); // allow EM DASH through
3130
return HtmlEncoder.Create(settings);

src/BenchmarksApps/TechEmpower/Minimal/Program.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
// Add services to the container.
2424
builder.Services.AddSingleton(new Db(appSettings));
2525
builder.Services.AddRazorComponents();
26+
builder.Services.AddSingleton(CreateHtmlEncoder());
2627

2728
var app = builder.Build();
2829

@@ -38,9 +39,7 @@
3839

3940
app.MapGet("/db/result", async (Db db) => Results.Json(await db.LoadSingleQueryRow()));
4041

41-
var htmlEncoder = CreateHtmlEncoder();
42-
43-
app.MapGet("/fortunes", async (HttpContext context, Db db) => {
42+
app.MapGet("/fortunes", async (HttpContext context, Db db, HtmlEncoder htmlEncoder) => {
4443
var fortunes = await db.LoadFortunesRows();
4544
//var fortunes = await db.LoadFortunesRowsNoDb(); // Don't call the database
4645
var template = (RazorSliceHttpResult<List<Fortune>>)Fortunes.Create(fortunes);

0 commit comments

Comments
 (0)