diff --git a/src/Dibix.Http.Client/Client/UriBuilder.cs b/src/Dibix.Http.Client/Client/UriBuilder.cs index 866d80df..3d96d61e 100644 --- a/src/Dibix.Http.Client/Client/UriBuilder.cs +++ b/src/Dibix.Http.Client/Client/UriBuilder.cs @@ -23,7 +23,7 @@ private UriBuilder(string url, UriKind kind) public UriBuilder AddQueryParam(string name, T value) where T : struct => this.AddQueryParam(name, ToString(value)); public UriBuilder AddQueryParam(string name, T value, T defaultValue) where T : struct => !Equals(value, defaultValue) ? AddQueryParam(name, ToString(value)) : this; - public UriBuilder AddQueryParam(string name, T? value) where T : struct => this.AddQueryParam(name, ToString(value)); + public UriBuilder AddQueryParam(string name, T? value) where T : struct => value != null ? AddQueryParam(name, ToString(value)) : this; public UriBuilder AddQueryParam(string name, T? value, T? defaultValue) where T : struct => !Equals(value, defaultValue) ? AddQueryParam(name, ToString(value)) : this; public UriBuilder AddQueryParam(string name, string value) { diff --git a/tests/Dibix.Http.Client.Tests/UriBuilderTest.cs b/tests/Dibix.Http.Client.Tests/UriBuilderTest.cs index 48dbc7dc..60302df9 100644 --- a/tests/Dibix.Http.Client.Tests/UriBuilderTest.cs +++ b/tests/Dibix.Http.Client.Tests/UriBuilderTest.cs @@ -11,9 +11,10 @@ public void CrossCheck() { Uri uri = UriBuilder.Create("some/kind/{of}/uri", UriKind.Relative) .AddQueryParam("name", "luke") - .AddQueryParam("id", (int?)null) - .AddQueryParam("omitnull", (int?)null, null) - .AddQueryParam("omitprimitive", 3, 3) + .AddQueryParam("id", "") + .AddQueryParam("omitnull", (int?)null) + .AddQueryParam("omitdefaultnull", (int?)null, null) + .AddQueryParam("omitdefaultprimitive", 3, 3) .AddQueryParam("bool", true) .AddQueryParam("array", "first") .AddQueryParam("array", "second")