mirror of
https://github.com/volodymyrsmirnov/MalwareMultiScan.git
synced 2025-08-25 22:01:16 +00:00
unit tests for API (99% coverage)
This commit is contained in:
@@ -6,14 +6,15 @@ namespace MalwareMultiScan.Api.Attributes
|
||||
/// <summary>
|
||||
/// Validate URI to be an absolute http(s) URL.
|
||||
/// </summary>
|
||||
internal class IsHttpUrlAttribute : ValidationAttribute
|
||||
public class IsHttpUrlAttribute : ValidationAttribute
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
|
||||
{
|
||||
if (!Uri.TryCreate((string)value, UriKind.Absolute, out var uri)
|
||||
|| !uri.IsAbsoluteUri
|
||||
|| uri.Scheme != "http" && uri.Scheme != "https")
|
||||
|| uri.Scheme.ToLowerInvariant() != "http"
|
||||
&& uri.Scheme.ToLowerInvariant() != "https")
|
||||
return new ValidationResult("Only absolute http(s) URLs are supported");
|
||||
|
||||
return ValidationResult.Success;
|
||||
|
Reference in New Issue
Block a user