Skip to content

Commit

Permalink
Fix Url Validator
Browse files Browse the repository at this point in the history
  • Loading branch information
marcussacana committed Sep 8, 2024
1 parent b558882 commit b5e72d5
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions DirectPackageInstaller/DirectPackageInstaller/Others/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Net;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text.Encodings.Web;
using System.Threading;
using System.Threading.Tasks;
using Avalonia.Controls;
Expand Down Expand Up @@ -97,8 +98,17 @@ void DialogClosed(object sender, EventArgs e)

public static bool IsValidURL(this string URL)
{
var Escaped = URL.Replace("[", "%5B").Replace("]", "%5D");
return Uri.IsWellFormedUriString(Escaped, UriKind.Absolute);
var Escaped = URL
.Replace("[", "%5B")
.Replace("]", "%5D");
try
{
return new Uri(Escaped).IsAbsoluteUri;
}
catch
{
return false;
}
}
public static bool HasName(this ParamSfo This, string name)
{
Expand Down

0 comments on commit b5e72d5

Please sign in to comment.