Closed Xeevis closed 6 years ago
I'm dynamically adding nodes from my menu provider
foreach (var menuItem in menu.Items) { nodes.AddRange(GetAllChildren(menuItem, c => c.Items).Select(x => new SitemapNode(x.Url))); }
And it happened I added menu item placeholder without an url, this resulted in invalid sitemap because absence of url renders invalid tag.
I had to add extra check to make sure that doesn't happen from my code.
.Where(x => !string.IsNullOrWhiteSpace(x?.Url))
It might be a good idea to add check that prevents rendering of SitemapNode when url is empty to prevent invalid sitemap scenario.
I think throwing an exception is no better than creating some invalid nodes. I certainly won't put filtering code for this scenario into the library. I think it's better if you do this check in your own code.
I'm dynamically adding nodes from my menu provider
And it happened I added menu item placeholder without an url, this resulted in invalid sitemap because absence of url renders invalid tag.
I had to add extra check to make sure that doesn't happen from my code.
It might be a good idea to add check that prevents rendering of SitemapNode when url is empty to prevent invalid sitemap scenario.