Skip to content

Commit 110d563

Browse files
committed
Address PR comments
1 parent b8803e4 commit 110d563

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

src/JsonApiDotNetCore/QueryStrings/QueryStringReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void ReadAll(DisableQueryStringAttribute? disableQueryStringAttribute)
4040
{
4141
if (parameterName.Length == 0)
4242
{
43-
throw new InvalidQueryException("Empty query string parameter name.", null);
43+
continue;
4444
}
4545

4646
IQueryStringParameterReader? reader = _parameterReaders.FirstOrDefault(nextReader => nextReader.CanRead(parameterName));

test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/QueryStringTests.cs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,28 +63,22 @@ public async Task Can_use_unknown_query_string_parameter()
6363
httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK);
6464
}
6565

66-
[Fact]
67-
public async Task Cannot_use_empty_query_string_parameter_name()
66+
[Theory]
67+
[InlineData("")]
68+
[InlineData("foo")]
69+
public async Task Should_ignore_query_parameter_with_empty_name(string parameterValue)
6870
{
6971
// Arrange
7072
var options = (JsonApiOptions)_testContext.Factory.Services.GetRequiredService<IJsonApiOptions>();
7173
options.AllowUnknownQueryStringParameters = false;
7274

73-
const string route = "calendars?=";
75+
string route = $"calendars?={parameterValue}";
7476

7577
// Act
76-
(HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecuteGetAsync<Document>(route);
78+
(HttpResponseMessage httpResponse, Document _) = await _testContext.ExecuteGetAsync<Document>(route);
7779

7880
// Assert
79-
httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest);
80-
81-
responseDocument.Errors.ShouldHaveCount(1);
82-
83-
ErrorObject error = responseDocument.Errors[0];
84-
error.StatusCode.Should().Be(HttpStatusCode.BadRequest);
85-
error.Title.Should().Be("Empty query string parameter name.");
86-
error.Detail.Should().BeNull();
87-
error.Source.Should().BeNull();
81+
httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK);
8882
}
8983

9084
[Theory]

0 commit comments

Comments
 (0)