Compare commits

...

3 Commits

Author SHA1 Message Date
Stef Heyenrath
b3c2af0c22 1.0.40.0 (changelog) 2019-12-09 17:32:47 +01:00
Stef Heyenrath
2dd30b4f14 1.0.40 2019-12-09 17:31:50 +01:00
Stef Heyenrath
45d8c0cc27 Fix QueryStringParser (#389)
* Fix QueryStringParser

* add extra test
2019-12-09 17:20:17 +01:00
6 changed files with 38 additions and 6 deletions

View File

@@ -1,3 +1,6 @@
# 1.0.40.0 (09 December 2019)
- [#389](https://github.com/WireMock-Net/WireMock.Net/pull/389) - Fix QueryStringParser [bug] contributed by [StefH](https://github.com/StefH)
# 1.0.39.0 (07 December 2019)
- [#370](https://github.com/WireMock-Net/WireMock.Net/pull/370) - Add WebProxySettings (use when proxying requests) [feature] contributed by [StefH](https://github.com/StefH)
- [#388](https://github.com/WireMock-Net/WireMock.Net/pull/388) - Transform body as file [bug] contributed by [StefH](https://github.com/StefH)

View File

@@ -4,7 +4,7 @@
</PropertyGroup>
<PropertyGroup>
<VersionPrefix>1.0.39</VersionPrefix>
<VersionPrefix>1.0.40</VersionPrefix>
</PropertyGroup>
<Choose>

View File

@@ -1,3 +1,3 @@
https://github.com/StefH/GitHubReleaseNotes
GitHubReleaseNotes.exe --output CHANGELOG.md --skip-empty-releases --exclude-labels question invalid doc --version 1.0.39.0
GitHubReleaseNotes.exe --output CHANGELOG.md --skip-empty-releases --exclude-labels question invalid doc --version 1.0.40.0

View File

@@ -170,7 +170,7 @@ namespace WireMock
Headers = headers?.ToDictionary(header => header.Key, header => new WireMockList<string>(header.Value));
Cookies = cookies;
RawQuery = WebUtility.UrlDecode(urlDetails.Url.Query);
RawQuery = urlDetails.Url.Query;
Query = QueryStringParser.Parse(RawQuery);
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
namespace WireMock.Util
{
@@ -30,7 +31,7 @@ namespace WireMock.Util
.Split(new[] { '&', ';' }, StringSplitOptions.RemoveEmptyEntries) // Support "?key=value;key=anotherValue" and "?key=value&key=anotherValue"
.Select(parameter => parameter.Split(new[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries))
.GroupBy(parts => parts[0], JoinParts)
.ToDictionary(grouping => grouping.Key, grouping => new WireMockList<string>(grouping.SelectMany(x => x)));
.ToDictionary(grouping => grouping.Key, grouping => new WireMockList<string>(grouping.SelectMany(x => x).Select(WebUtility.UrlDecode)));
}
}
}

View File

@@ -188,6 +188,34 @@ namespace WireMock.Net.Tests.Util
result["key"].Should().Equal(new WireMockList<string>(new[] { "1", "2", "3" }));
}
[Fact]
public void Parse_With1ParamContainingEscapedAnd()
{
// Assign
string query = "?winkel=C%26A";
// Act
var result = QueryStringParser.Parse(query);
// Assert
result.Count.Should().Be(1);
result["winkel"].Should().Equal(new WireMockList<string>(new[] { "C&A" }));
}
[Fact]
public void Parse_With1ParamContainingParentheses()
{
// Assign
string query = "?Transaction=(123)";
// Act
var result = QueryStringParser.Parse(query);
// Assert
result.Count.Should().Be(1);
result["Transaction"].Should().Equal(new WireMockList<string>(new[] { "(123)" }));
}
[Fact]
public void Parse_WithMultipleParamWithSameKey()
{
@@ -227,12 +255,12 @@ namespace WireMock.Net.Tests.Util
// Assert
result.Count.Should().Be(6);
result["q"].Should().Equal(new WireMockList<string>("energy+edge"));
result["q"].Should().Equal(new WireMockList<string>("energy edge"));
result["rls"].Should().Equal(new WireMockList<string>("com.microsoft:en-au"));
result["ie"].Should().Equal(new WireMockList<string>("UTF-8"));
result["oe"].Should().Equal(new WireMockList<string>("UTF-8"));
result["startIndex"].Should().Equal(new WireMockList<string>());
result["startPage"].Should().Equal(new WireMockList<string>("1%22"));
result["startPage"].Should().Equal(new WireMockList<string>("1\""));
}
}
}