Skip to content

Commit

Permalink
Code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahelsaig committed Jan 10, 2024
1 parent b1a6a07 commit 49940d6
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mime;
using System.Threading.Tasks;
using static Lombiq.HelpfulLibraries.AspNetCore.Security.ContentSecurityPolicyDirectives;
using static Lombiq.HelpfulLibraries.AspNetCore.Security.ContentSecurityPolicyDirectives.CommonValues;
Expand Down Expand Up @@ -62,7 +63,7 @@ public static IApplicationBuilder UseContentSecurityPolicyHeader(
context.Response.OnStarting(async () =>
{
// No need to do content security policy on non-HTML responses.
if (context.Response.ContentType?.ContainsOrdinalIgnoreCase("text/html") != true) return;
if (context.Response.ContentType?.ContainsOrdinalIgnoreCase(MediaTypeNames.Text.Html) != true) return;
// The thought behind this provider model is that if you need something else than the default, you should
// add a provider that only applies the additional directive on screens where it's actually needed. This way
Expand All @@ -72,7 +73,7 @@ public static IApplicationBuilder UseContentSecurityPolicyHeader(
await provider.UpdateAsync(securityPolicies, context);
}
var policy = string.Join("; ", EnumerableExtensions.Select(securityPolicies, (key, value) => $"{key} {value}"));
var policy = string.Join("; ", securityPolicies.Select(pair => $"{pair.Key} {pair.Value}"));
context.Response.Headers[key] = policy;
});
Expand Down

0 comments on commit 49940d6

Please sign in to comment.