mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
catch if URL is improperly formatted
This commit is contained in:
parent
0097ddd3e0
commit
e200bad9e5
1 changed files with 8 additions and 0 deletions
|
|
@ -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 =
|
||||
|
|
|
|||
Loading…
Reference in a new issue