[Fix] URL encode timestamps sent as query parameters (#2770)

* [Fix] URL encode timestamps sent as query parameters
This commit is contained in:
Sauceke
2023-09-02 18:53:30 +02:00
committed by GitHub
parent 75cf622771
commit 589c58adb0

View File

@@ -618,11 +618,13 @@ namespace Discord.API
if (limit.HasValue)
{
query = $"?before={before.GetValueOrDefault(DateTimeOffset.UtcNow).ToString("O")}&limit={limit.Value}";
string beforeEncoded = WebUtility.UrlEncode(before.GetValueOrDefault(DateTimeOffset.UtcNow).ToString("O"));
query = $"?before={beforeEncoded}&limit={limit.Value}";
}
else if (before.HasValue)
{
query = $"?before={before.Value.ToString("O")}";
string beforeEncoded = WebUtility.UrlEncode(before.Value.ToString("O"));
query = $"?before={beforeEncoded}";
}
return await SendAsync<ChannelThreads>("GET", () => $"channels/{channelId}/threads/archived/public{query}", bucket, options: options);
@@ -641,11 +643,13 @@ namespace Discord.API
if (limit.HasValue)
{
query = $"?before={before.GetValueOrDefault(DateTimeOffset.UtcNow).ToString("O")}&limit={limit.Value}";
string beforeEncoded = WebUtility.UrlEncode(before.GetValueOrDefault(DateTimeOffset.UtcNow).ToString("O"));
query = $"?before={beforeEncoded}&limit={limit.Value}";
}
else if (before.HasValue)
{
query = $"?before={before.Value.ToString("O")}";
string beforeEncoded = WebUtility.UrlEncode(before.Value.ToString("O"));
query = $"?before={beforeEncoded}";
}
return await SendAsync<ChannelThreads>("GET", () => $"channels/{channelId}/threads/archived/private{query}", bucket, options: options);