Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

url validation #1438

Merged
merged 10 commits into from
May 23, 2024
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
Loading