diff --git a/src/Discord.Net.Core/Format.cs b/src/Discord.Net.Core/Format.cs index 49d34613e..55161b21d 100644 --- a/src/Discord.Net.Core/Format.cs +++ b/src/Discord.Net.Core/Format.cs @@ -47,8 +47,10 @@ namespace Discord /// Gets the formatted quote text. // TODO: better xmldoc public static string Quote(string text) { - if (text == null) - return null; + // do not modify null or whitespace text + // whitespace does not get quoted properly + if (string.IsNullOrWhiteSpace(text)) + return text; StringBuilder result = new StringBuilder(); diff --git a/test/Discord.Net.Tests.Unit/FormatTests.cs b/test/Discord.Net.Tests.Unit/FormatTests.cs index 7877d5fdc..c3737af8e 100644 --- a/test/Discord.Net.Tests.Unit/FormatTests.cs +++ b/test/Discord.Net.Tests.Unit/FormatTests.cs @@ -35,9 +35,9 @@ namespace Discord Assert.Null(Format.Quote(null)); } [Theory] - [InlineData("", "> ")] - [InlineData("\n", "> \n")] - [InlineData("\n ", "> \n> ")] + [InlineData("", "")] + [InlineData("\n", "\n")] + [InlineData("foo\n\nbar", "> foo\n> \n> bar")] [InlineData("input", "> input")] // single line // should work with CR or CRLF [InlineData("inb4\ngreentext", "> inb4\n> greentext")]