Skip to content

Commit

Permalink
fix nodes null exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-b-iodigital committed Mar 5, 2024
1 parent 127af91 commit 2fc188e
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -296,19 +296,22 @@ private async Task CreateEntry(ApplicationDbContext db, string tenantId, Website

var nodes = htmlDoc.DocumentNode.SelectNodes("//main");

foreach (var node in nodes)
if (nodes != null)
{
var cleanText = Regex.Replace(node.InnerText, @"\s+", " ").Trim();
cleanText = WebUtility.HtmlDecode(cleanText);

if (!string.IsNullOrEmpty(cleanText))
foreach (var node in nodes)
{
var chunkResult = new ChunkResult();
chunkResult.ArticleNumber = string.Empty;
chunkResult.Text = cleanText;
chunkResult.Packaging = string.Empty;
var cleanText = Regex.Replace(node.InnerText, @"\s+", " ").Trim();
cleanText = WebUtility.HtmlDecode(cleanText);

chunks.Add(chunkResult);
if (!string.IsNullOrEmpty(cleanText))
{
var chunkResult = new ChunkResult();
chunkResult.ArticleNumber = string.Empty;
chunkResult.Text = cleanText;
chunkResult.Packaging = string.Empty;

chunks.Add(chunkResult);
}
}
}

Expand Down

0 comments on commit 2fc188e

Please sign in to comment.