fix(bot): make pk;import handle <>
wrapped URLs
This commit is contained in:
parent
10287d0146
commit
683b616a1b
@ -33,10 +33,10 @@ public class ImportExport
|
||||
|
||||
public async Task Import(Context ctx)
|
||||
{
|
||||
var url = ctx.RemainderOrNull() ?? ctx.Message.Attachments.FirstOrDefault()?.Url;
|
||||
if (url == null) throw Errors.NoImportFilePassed;
|
||||
var inputUrl = ctx.RemainderOrNull() ?? ctx.Message.Attachments.FirstOrDefault()?.Url;
|
||||
if (inputUrl == null) throw Errors.NoImportFilePassed;
|
||||
|
||||
if (!Core.MiscUtils.TryMatchUri(url, out var _))
|
||||
if (!Core.MiscUtils.TryMatchUri(inputUrl, out var url))
|
||||
throw Errors.InvalidUrl;
|
||||
|
||||
await ctx.BusyIndicator(async () =>
|
||||
|
@ -13,6 +13,9 @@ public static class MiscUtils
|
||||
|
||||
public static bool TryMatchUri(string input, out Uri uri)
|
||||
{
|
||||
if (input.StartsWith('<') && input.EndsWith('>'))
|
||||
input = input[1..^1];
|
||||
|
||||
try
|
||||
{
|
||||
uri = new Uri(input);
|
||||
|
Loading…
Reference in New Issue
Block a user