Skip to content

Commit

Permalink
Merge pull request #1438 from ita-social-projects/url-validation-1117
Browse files Browse the repository at this point in the history
url validation
  • Loading branch information
Shossy authored May 23, 2024
2 parents a907d86 + 012aaff commit 611b638
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using AutoMapper;
using AutoMapper;
using FluentResults;
using MediatR;
using Microsoft.Extensions.Localization;
Expand Down Expand Up @@ -48,11 +48,14 @@ public async Task<Result<NewsDTO>> Handle(CreateNewsCommand request, Cancellatio
return Result.Fail(errorMsg);
}

if (newNews.URL.Contains("/"))
foreach (char c in newNews.URL)
{
string errorMsg = "Url Is Invalid";
_logger.LogError(request, errorMsg);
return Result.Fail(errorMsg);
if (!((c >= 'a' && c <= 'z') || char.IsDigit(c) || c == '-') || (c >= 'A' && c <= 'Z'))
{
string errorMsg = "Url Is Invalid";
_logger.LogError(request, errorMsg);
return Result.Fail(errorMsg);
}
}

if (newNews.CreationDate == default(DateTime))
Expand Down

0 comments on commit 611b638

Please sign in to comment.