Skip to content

Commit

Permalink
url validation
Browse files Browse the repository at this point in the history
  • Loading branch information
xubiod committed Jul 21, 2020
1 parent dd3c4cd commit 031d1f5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions xubot-core/src/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -440,5 +440,11 @@ public static DateTime UnixTimeStampToDateTime(ulong unixTimeStamp)
dtDateTime = dtDateTime.AddSeconds(unixTimeStamp).ToLocalTime();
return dtDateTime;
}

public static bool ValidateURL(string url)
{
Uri result;
return Uri.TryCreate(url, UriKind.Absolute, out result) && (result.Scheme == Uri.UriSchemeHttp || result.Scheme == Uri.UriSchemeHttps);
}
}
}

0 comments on commit 031d1f5

Please sign in to comment.