Fix QueryStringParser (#389)

* Fix QueryStringParser

* add extra test
This commit is contained in:
Stef Heyenrath
2019-12-09 17:20:17 +01:00
committed by GitHub
parent 178f2cf02f
commit 45d8c0cc27
3 changed files with 33 additions and 4 deletions

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)));
}
}
}