Skip to content

Commit

Permalink
Silently return null if the passed key to FindSiteMapNodeFromKey isn'…
Browse files Browse the repository at this point in the history
…t a valid Guid
  • Loading branch information
burningice2866 committed Mar 5, 2020
1 parent 1c053cf commit b15033d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Composite/AspNet/CmsPagesSiteMapPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,16 @@ public SiteMapNode FindSiteMapNode(SiteMapProvider provider, string rawUrl)
/// <exclude />
public SiteMapNode FindSiteMapNodeFromKey(SiteMapProvider provider, string key)
{
var pageId = new Guid(key);
var page = PageManager.GetPageById(pageId);
if (Guid.TryParse(key, out var pageId))
{
var page = PageManager.GetPageById(pageId);
if (page != null)
{
return new CmsPageSiteMapNode(provider, page);
}
}

return page != null ? new CmsPageSiteMapNode(provider, page) : null;
return null;
}

/// <exclude />
Expand Down

0 comments on commit b15033d

Please sign in to comment.