Skip to content

Commit

Permalink
🐛 (TfsEndpointOptions.cs): improve URL validation logic for Collectio…
Browse files Browse the repository at this point in the history
…n property

The previous implementation used `Uri.IsWellFormedUriString` which is less robust. The new implementation uses `Uri.TryCreate` to ensure the Collection property is a valid URL, providing more accurate validation and error handling. This change enhances the reliability of the URL validation process.
  • Loading branch information
MrHinsh committed Sep 23, 2024
1 parent 822ef81 commit a8f0fd4
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,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(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 +71,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

0 comments on commit a8f0fd4

Please sign in to comment.