catch if URL is improperly formatted

This commit is contained in:
Collin M. Barrett 2019-07-13 14:09:50 -05:00
parent 0097ddd3e0
commit e200bad9e5

View file

@ -27,6 +27,14 @@ public UrlValidator(HttpClient httpClient, ILogger<UrlValidator> logger)
public async Task<EntityUrl> ValidateAsync(EntityUrl entityUrl, CancellationToken cancellationToken)
{
var url = entityUrl.Url;
if (!Uri.IsWellFormedUriString(url.OriginalString, UriKind.Absolute))
{
entityUrl.SetBroken();
_logger.LogError(
$"Url validation for ({url.OriginalString}) failed because it appears to be improperly formatted.");
return entityUrl;
}
try
{
using var response =