Skip to content

Commit

Permalink
Merge pull request #1 from mariusz96/bugfix
Browse files Browse the repository at this point in the history
Fix bug in path validation
  • Loading branch information
Swimburger authored May 21, 2024
2 parents 4c51348 + 32d2869 commit 664bcd2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion UrlShortener.Data/ShortUrlValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ public static bool ValidatePath(string? path, out string[] validationResults)
validationResultsList.Add("Path can only contain alphanumeric characters, underscores, and dashes.");

validationResults = validationResultsList.ToArray();
return validationResultsList.Count > 0;
return validationResultsList.Count == 0;
}
}
4 changes: 2 additions & 2 deletions UrlShortener.Forwarder/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
ShortUrlRepository shortUrlRepository
) =>
{
if(ShortUrlValidator.ValidatePath(path, out _))
return Results.BadRequest();
if (!ShortUrlValidator.ValidatePath(path, out var validationResults))
return Results.BadRequest(validationResults);

var shortUrl = await shortUrlRepository.Get(path);
if (shortUrl == null || string.IsNullOrEmpty(shortUrl.Destination))
Expand Down

0 comments on commit 664bcd2

Please sign in to comment.