Skip to content

Commit

Permalink
Update config retrieval method and add null check
Browse files Browse the repository at this point in the history
Changed the retrieval of `pingTargets` from `GetValue<string[]>("PingTargets")` to `GetSection("PingTargets").Get<string[]>()`. Added a null check to return the `services` object immediately if `pingTargets` is null.
  • Loading branch information
EdiWang committed Feb 4, 2025
1 parent 5904197 commit fa4372c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Moonglade.IndexNow.Client/ServiceCollectionExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public static class ServiceCollectionExtension
{
public static IServiceCollection AddIndexNowClient(this IServiceCollection services, IConfigurationSection configurationSection)
{
var pingTargets = configurationSection.GetValue<string[]>("PingTargets");
var pingTargets = configurationSection.GetSection("PingTargets").Get<string[]>();
if (null == pingTargets) return services;

foreach (var pingTarget in pingTargets)
{
Expand Down

0 comments on commit fa4372c

Please sign in to comment.