mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-16 15:16:53 +01:00
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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\""));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user