diff --git a/CHANGELOG.md b/CHANGELOG.md index 79617892..400a8453 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ # Changelog -## Unreleased +## 4.1.1 -- +- fix: data escaped + (plus) was not parsed correctly, caused by [#68](https://github.com/skwasjer/MockHttp/pull/68). My apologies... :) ## v4.1.0 diff --git a/src/MockHttp/Http/DataEscapingHelper.cs b/src/MockHttp/Http/DataEscapingHelper.cs index 2564f33a..18fd04ea 100644 --- a/src/MockHttp/Http/DataEscapingHelper.cs +++ b/src/MockHttp/Http/DataEscapingHelper.cs @@ -50,7 +50,7 @@ internal static IEnumerable>> Parse(str private static string UnescapeData(string v) { - return Uri.UnescapeDataString(v).Replace('+', ' '); + return Uri.UnescapeDataString(v?.Replace("+", "%20")!); } internal static string Format(IEnumerable> items) diff --git a/test/MockHttp.Tests/Http/DataEscapingHelperTests.cs b/test/MockHttp.Tests/Http/DataEscapingHelperTests.cs index a15bf9ab..9f1a7236 100644 --- a/test/MockHttp.Tests/Http/DataEscapingHelperTests.cs +++ b/test/MockHttp.Tests/Http/DataEscapingHelperTests.cs @@ -54,9 +54,11 @@ public void Given_escapedString_contains_multiple_same_keys_when_parsing_should_ [InlineData("key", "key", "a%20b", "a b")] [InlineData("key", "key", "a+b", "a b")] [InlineData("key", "key", "a b", "a b")] + [InlineData("key", "key", "a%2Bb", "a+b")] [InlineData("a%20b", "a b", "value", "value")] [InlineData("a+b", "a b", "value", "value")] [InlineData("a b", "a b", "value", "value")] + [InlineData("a%2Bb", "a+b", "value", "value")] public void Given_escapedString_contains_space_when_parsing_it_should_return_expected(string key, string expectedKey, string value, string expectedValue) { var expected = new Dictionary> { { expectedKey, new[] { expectedValue } } };