File tree 2 files changed +23
-0
lines changed
src/JsonApiDotNetCore/QueryStrings
test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings
2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,11 @@ public void ReadAll(DisableQueryStringAttribute? disableQueryStringAttribute)
38
38
39
39
foreach ( ( string parameterName , StringValues parameterValue ) in _queryStringAccessor . Query )
40
40
{
41
+ if ( parameterName . Length == 0 )
42
+ {
43
+ continue ;
44
+ }
45
+
41
46
IQueryStringParameterReader ? reader = _parameterReaders . FirstOrDefault ( nextReader => nextReader . CanRead ( parameterName ) ) ;
42
47
43
48
if ( reader != null )
Original file line number Diff line number Diff line change @@ -63,6 +63,24 @@ public async Task Can_use_unknown_query_string_parameter()
63
63
httpResponse . ShouldHaveStatusCode ( HttpStatusCode . OK ) ;
64
64
}
65
65
66
+ [ Theory ]
67
+ [ InlineData ( "" ) ]
68
+ [ InlineData ( "bar" ) ]
69
+ public async Task Can_use_empty_query_string_parameter_name ( string parameterValue )
70
+ {
71
+ // Arrange
72
+ var options = ( JsonApiOptions ) _testContext . Factory . Services . GetRequiredService < IJsonApiOptions > ( ) ;
73
+ options . AllowUnknownQueryStringParameters = false ;
74
+
75
+ string route = $ "calendars?={ parameterValue } ";
76
+
77
+ // Act
78
+ ( HttpResponseMessage httpResponse , Document _ ) = await _testContext . ExecuteGetAsync < Document > ( route ) ;
79
+
80
+ // Assert
81
+ httpResponse . ShouldHaveStatusCode ( HttpStatusCode . OK ) ;
82
+ }
83
+
66
84
[ Theory ]
67
85
[ InlineData ( "filter" ) ]
68
86
[ InlineData ( "sort" ) ]
You can’t perform that action at this time.
0 commit comments