From fe07a83f1f5f8da9886f426fe21f038b61693123 Mon Sep 17 00:00:00 2001 From: Christopher F Date: Fri, 19 Oct 2018 17:22:02 -0400 Subject: [PATCH] fix: strip trailing slash from ratelimit bucket IDs (#1163) * fix: strip trailing slash from ratelimit bucket IDs This resolves #1125. fixes a bug where some ratelimit buckets would include a trailing slash, while others wouldn't; this would cause them to be treated as separate ratelimits, even though they are the same ideally this fix should change the ratelimit generator, but that code is pretty complicated and this was an easier fix that seems less likely to break things in the future. tested against normal bot function, all routes are assigned the proper buckets from my testing, so this should be good to go. * lint: use more performant algorithm, operate on StringBuilder --- src/Discord.Net.Rest/DiscordRestApiClient.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Discord.Net.Rest/DiscordRestApiClient.cs b/src/Discord.Net.Rest/DiscordRestApiClient.cs index 36406bfea..284a51756 100644 --- a/src/Discord.Net.Rest/DiscordRestApiClient.cs +++ b/src/Discord.Net.Rest/DiscordRestApiClient.cs @@ -1,3 +1,4 @@ + #pragma warning disable CS1591 using Discord.API.Rest; using Discord.Net; @@ -1426,8 +1427,11 @@ namespace Discord.API lastIndex = rightIndex + 1; } + if (builder[builder.Length - 1] == '/') + builder.Remove(builder.Length - 1, 1); format = builder.ToString(); + return x => string.Format(format, x.ToArray()); } catch (Exception ex)