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

🐛 (TfsEndpointOptions.cs): improve URL validation logic for Collection property #2388

Merged
merged 3 commits into from
Sep 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text.Encodings.Web;
using Microsoft.Extensions.Options;
using MigrationTools.Endpoints.Infrastructure;
using Newtonsoft.Json;
Expand Down Expand Up @@ -42,9 +43,14 @@ public ValidateOptionsResult Validate(string name, TfsEndpointOptions options)
{
errors.Add("The Collection property must not be null.");
}
else if (!Uri.IsWellFormedUriString(options.Collection.ToString(), UriKind.Absolute))
else
{
errors.Add("The Collection property must be a valid URL.");
Uri output;
if (!Uri.TryCreate(Uri.UnescapeDataString(options.Collection.ToString()), UriKind.Absolute, out output))
{
errors.Add("The Collection property must be a valid URL.");
}

}

// Validate Project - Must not be null or empty
Expand All @@ -66,7 +72,7 @@ public ValidateOptionsResult Validate(string name, TfsEndpointOptions options)
}
else
{
ValidateOptionsResult lmr= options.LanguageMaps.Validate(name, options.LanguageMaps);
ValidateOptionsResult lmr = options.LanguageMaps.Validate(name, options.LanguageMaps);
if (lmr != ValidateOptionsResult.Success)
{
errors.AddRange(lmr.Failures);
Expand Down
Loading