Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@

### 🛠 Technical

- Minor bug fixes on tools (CI, csproj, etc...)
- Minor bug fixes on tools (CI, csproj, etc...)

## 202

### 🐛 Bug Fixes

- Fixed a bug where the entire query string was encoded instead of only the query parameter keys and values.
20 changes: 10 additions & 10 deletions NotoriousClient.Tests.Unit/RequestBuilderURIUnitTests.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
using NotoriousClient.Builder;
using NotoriousClient.Builder;
using NotoriousClient.Tests.Unit.Attributes;

namespace NotoriousClient.Tests.Unit
{
public class RequestBuilderURIUnitTests
{
#region URI
[GWTFact(given: "a url, an endpoint, and an HTTP Verb",
when: "i build a request",
[GWTFact(given: "a url, an endpoint, and an HTTP Verb",
when: "i build a request",
then: "request has right url, endpoint and verb")]
public void RequestBuilder_Should_HaveRightUrlEndpointAndVerb()
{
string url = "https://toto.com";
Endpoint endpoint = new Endpoint("/pandas", Method.Get);

RequestBuilder requestBuilder = new RequestBuilder(url, endpoint);
HttpRequestMessage request = requestBuilder.Build();
HttpRequestMessage request = requestBuilder.Build();

Assert.Equal(HttpMethod.Get, request.Method);
Assert.NotNull(request.RequestUri);
Assert.Equal("https://toto.com/pandas", request.RequestUri!.ToString());
Assert.Equal("https://toto.com/pandas", request.RequestUri.AbsoluteUri);
}

[GWTFact(given: "a url with and end slash, an endpoint with a start slash, and an HTTP Verb",
Expand All @@ -35,7 +35,7 @@ public void RequestBuilder_Should_HandleUrlSlashProperly()

Assert.Equal(HttpMethod.Get, request.Method);
Assert.NotNull(request.RequestUri);
Assert.Equal("https://toto.com/pandas", request.RequestUri!.ToString());
Assert.Equal("https://toto.com/pandas", request.RequestUri.AbsoluteUri);
}

[GWTFact(given: "a url, an endpoint, and an HTTP Verb",
Expand All @@ -51,7 +51,7 @@ public void RequestBuilder_Should_AddUrlSlashProperly()

Assert.Equal(HttpMethod.Get, request.Method);
Assert.NotNull(request.RequestUri);
Assert.Equal("https://toto.com/pandas", request.RequestUri!.ToString());
Assert.Equal("https://toto.com/pandas", request.RequestUri.AbsoluteUri);
}
#endregion

Expand All @@ -70,7 +70,7 @@ public void RequestBuilder_Should_HaveOneQueryParams()

Assert.Equal(HttpMethod.Get, request.Method);
Assert.NotNull(request.RequestUri);
Assert.Equal("https://toto.com/pandas?toto%3dtoto", request.RequestUri!.ToString());
Assert.Equal("https://toto.com/pandas?toto=toto", request.RequestUri.AbsoluteUri);
}

[GWTFact(given: "a request with two query parameters",
Expand All @@ -88,7 +88,7 @@ public void RequestBuilder_Should_HaveTwoQueryParams()

Assert.Equal(HttpMethod.Get, request.Method);
Assert.NotNull(request.RequestUri);
Assert.Equal("https://toto.com/pandas?toto%3dtoto%26toto2%3dtoto2", request.RequestUri!.ToString());
Assert.Equal("https://toto.com/pandas?toto=toto&toto2=toto2", request.RequestUri.AbsoluteUri);
}
#endregion

Expand All @@ -107,7 +107,7 @@ public void RequestBuilder_Should_HandleEndpointParams()

Assert.Equal(HttpMethod.Get, request.Method);
Assert.NotNull(request.RequestUri);
Assert.Equal("https://toto.com/pandas/1", request.RequestUri!.ToString());
Assert.Equal("https://toto.com/pandas/1", request.RequestUri.AbsoluteUri);
}

[GWTFact(given: "a request with one endpoint parameters and an endpoint without replacement token",
Expand Down
9 changes: 2 additions & 7 deletions NotoriousClient/Builder/RequestBuilder.Uri.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Specialized;
using System.Web;

namespace NotoriousClient.Builder
namespace NotoriousClient.Builder
{
public partial class RequestBuilder : IRequestBuilder
{
Expand Down Expand Up @@ -83,13 +79,12 @@ private string HandleUriQueryParams(string uri, Dictionary<string, string> query
if (queryParams.Count > 0)
{
string queryParamsString = string.Join("&", queryParams.Select(kvp => string.Format("{0}={1}", kvp.Key, kvp.Value)));
return string.Format(uri + "?{0}", HttpUtility.UrlEncode(queryParamsString));
return string.Format(uri + "?{0}", queryParamsString);
}
else
{
return uri;
}

}

private string HandleUriEndPointParams(string uri, Dictionary<string, string> endPointParams)
Expand Down
2 changes: 1 addition & 1 deletion NotoriousClient/NotoriousClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<PackageId>NotoriousClient</PackageId>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<VersionPrefix>2.0.1</VersionPrefix>
<VersionPrefix>2.0.2</VersionPrefix>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Authors>Brice SCHUMACHER</Authors>
<RepositoryUrl>https://github.com/Notorious-Coding/Notorious-Client/</RepositoryUrl>
Expand Down
Loading