File tree 2 files changed +8
-14
lines changed
src/JsonApiDotNetCore/QueryStrings
test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings
2 files changed +8
-14
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ public void ReadAll(DisableQueryStringAttribute? disableQueryStringAttribute)
40
40
{
41
41
if ( parameterName . Length == 0 )
42
42
{
43
- throw new InvalidQueryException ( "Empty query string parameter name." , null ) ;
43
+ continue ;
44
44
}
45
45
46
46
IQueryStringParameterReader ? reader = _parameterReaders . FirstOrDefault ( nextReader => nextReader . CanRead ( parameterName ) ) ;
Original file line number Diff line number Diff line change @@ -63,28 +63,22 @@ public async Task Can_use_unknown_query_string_parameter()
63
63
httpResponse . ShouldHaveStatusCode ( HttpStatusCode . OK ) ;
64
64
}
65
65
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 )
68
70
{
69
71
// Arrange
70
72
var options = ( JsonApiOptions ) _testContext . Factory . Services . GetRequiredService < IJsonApiOptions > ( ) ;
71
73
options . AllowUnknownQueryStringParameters = false ;
72
74
73
- const string route = "calendars?=" ;
75
+ string route = $ "calendars?={ parameterValue } ";
74
76
75
77
// Act
76
- ( HttpResponseMessage httpResponse , Document responseDocument ) = await _testContext . ExecuteGetAsync < Document > ( route ) ;
78
+ ( HttpResponseMessage httpResponse , Document _ ) = await _testContext . ExecuteGetAsync < Document > ( route ) ;
77
79
78
80
// 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 ) ;
88
82
}
89
83
90
84
[ Theory ]
You can’t perform that action at this time.
0 commit comments