Skip to content

Commit

Permalink
Merge branch 'AddNullChecksOnNavigationNodes' of https://github.com/K…
Browse files Browse the repository at this point in the history
  • Loading branch information
jansenbe committed Oct 5, 2021
2 parents d211b33 + aa8190d commit 03390b4
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/lib/PnP.Framework/Extensions/NavigationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ public static string GetFooterTitle(this Web web)
var structureString = web.ExecuteGetAsync($"/_api/navigation/MenuState?menuNodeKey='{Constants.SITEFOOTER_NODEKEY}'").GetAwaiter().GetResult();
var menuState = JsonSerializer.Deserialize<JsonElement>(structureString);

if (menuState.GetProperty("Nodes").ValueKind == JsonValueKind.Null)
if (!menuState.TryGetProperty("Nodes", out JsonElement nodesElement) || nodesElement.ValueKind == JsonValueKind.Null)
{
// No information is returned which helps us to identity the title node
return null;
Expand Down Expand Up @@ -866,9 +866,8 @@ public static string GetFooterLogoUrl(this Web web)
{
var structureString = web.ExecuteGetAsync($"/_api/navigation/MenuState?menuNodeKey='{Constants.SITEFOOTER_NODEKEY}'").GetAwaiter().GetResult();
var menuState = JsonSerializer.Deserialize<JsonElement>(structureString);
//var menuState = JObject.Parse(structureString);

if (menuState.GetProperty("Nodes").ValueKind == JsonValueKind.Null)
if (!menuState.TryGetProperty("Nodes", out JsonElement nodesElement) || nodesElement.ValueKind == JsonValueKind.Null)
{
// No information is returned which helps us to identity the logo node
return null;
Expand Down

0 comments on commit 03390b4

Please sign in to comment.