Skip to content

Commit

Permalink
fix: data escaped + (plus) was not parsed correctly.
Browse files Browse the repository at this point in the history
Caused by: #68
  • Loading branch information
skwasjer committed Aug 13, 2023
1 parent 9aad655 commit ff53ce1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/MockHttp/Http/DataEscapingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal static IEnumerable<KeyValuePair<string, IEnumerable<string>>> Parse(str

private static string UnescapeData(string v)
{
return Uri.UnescapeDataString(v).Replace('+', ' ');
return Uri.UnescapeDataString(v?.Replace("+", "%20")!);
}

internal static string Format(IEnumerable<KeyValuePair<string, string>> items)
Expand Down
2 changes: 2 additions & 0 deletions test/MockHttp.Tests/Http/DataEscapingHelperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, IEnumerable<string>> { { expectedKey, new[] { expectedValue } } };
Expand Down

0 comments on commit ff53ce1

Please sign in to comment.