summaryrefslogtreecommitdiffstats
path: root/src/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/server')
-rw-r--r--src/server/Api/Internal/GetSiteReportRoute.cs12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/server/Api/Internal/GetSiteReportRoute.cs b/src/server/Api/Internal/GetSiteReportRoute.cs
index 58d6637..8b22795 100644
--- a/src/server/Api/Internal/GetSiteReportRoute.cs
+++ b/src/server/Api/Internal/GetSiteReportRoute.cs
@@ -32,9 +32,15 @@ public class GetSiteReportRoute : RouteBaseInternalAsync.WithRequest<GetSiteRepo
try {
var document = new HtmlDocument();
document.Load(await http_request.Content.ReadAsStreamAsync(cancellationToken));
- var htmlNodes = document.DocumentNode.Descendants("meta")
- .Where(p => p.GetAttributeValue("name", string.Empty).Equals("description", StringComparison.InvariantCultureIgnoreCase));
- report.Description = htmlNodes.FirstOrDefault()?.GetAttributeValue("content", string.Empty);
+ var descriptions = document.DocumentNode.Descendants("meta")
+ .Where(p => p.GetAttributeValue("name", string.Empty).Equals("description", StringComparison.InvariantCultureIgnoreCase));
+ var description = descriptions.FirstOrDefault()?.GetAttributeValue("content", string.Empty);
+ if (description.HasValue()) {
+ report.Description = description;
+ } else {
+ var title = document.DocumentNode.Descendants("title").FirstOrDefault()?.InnerText;
+ report.Description = title;
+ }
} catch (Exception e) {
_logger.LogWarning(e, "An error occured when parsing site for site report");
}