Merge pull request #316 from spiralw/feat/checkpatch

API patch improvements
This commit is contained in:
Astrid 2021-05-07 10:39:22 +02:00 committed by GitHub
commit 411cbdcd58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 103 additions and 22 deletions

View file

@ -25,17 +25,8 @@ namespace PluralKit.Bot {
using (var client = new HttpClient())
{
Uri uri;
try
{
uri = new Uri(url);
if (!uri.IsAbsoluteUri || (uri.Scheme != "http" && uri.Scheme != "https"))
throw Errors.InvalidUrl(url);
}
catch (UriFormatException)
{
if (!PluralKit.Core.MiscUtils.TryMatchUri(url, out var uri))
throw Errors.InvalidUrl(url);
}
var response = await client.GetAsync(uri);
if (!response.IsSuccessStatusCode) // Check status code