Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed json line ending trimming

  • Loading branch information...
commit c26ee3b5edc654bab4ee825afc83503faff7e388 1 parent 2ed7a04
@thecodejunkie thecodejunkie authored
View
11 src/Nancy.Tests/Unit/ModelBinding/DefaultBodyDeserializers/JsonBodyDeserializerFixture.cs
@@ -13,6 +13,7 @@ namespace Nancy.Tests.Unit.ModelBinding.DefaultBodyDeserializers
using Nancy.ModelBinding.DefaultBodyDeserializers;
using Xunit;
+ using Xunit.Extensions;
public class JsonBodyDeserializerFixture
{
@@ -248,11 +249,15 @@ public void Should_Serialize_Doubles_In_Different_Cultures()
#endif
- [Fact]
- public void Should_Serialize_Last_Prop_is_Bool_And_Trailing_NewLine()
+ [Theory]
+ [InlineData("\n")]
+ [InlineData("\n\r")]
+ [InlineData("\r\n")]
+ [InlineData("\r")]
+ public void Should_Serialize_Last_Prop_is_Bool_And_Trailing_NewLine(string lineEndings)
{
// Given
- var json = "{\"Property\": true\r\n}";
+ var json = string.Concat("{\"Property\": true", lineEndings, "}");
// When
var s = new JavaScriptSerializer();
View
2  src/Nancy/Json/JsonDeserializer.cs
@@ -495,7 +495,7 @@ bool ParseBuffer (out object result)
if (jsonType != JsonType.STRING)
{
- s = s.TrimEnd(Environment.NewLine.ToCharArray());
+ s = s.TrimEnd(new[] { '\n', '\r' });
}
switch (jsonType) {
Please sign in to comment.
Something went wrong with that request. Please try again.