@@ -14,23 +14,36 @@ public ReadStreamOperation(HttpRequest request)
1414 {
1515 StreamId = request . Path . Value . Remove ( 0 , 1 ) ;
1616
17- EmbedPayload = request . Query . TryGetValue ( "e" , out _ ) ;
17+ EmbedPayload = request . Query . TryGetValueCaseInsensitive ( 'e' , out _ ) ;
1818
19- ReadDirection = request . Query [ "d" ] == "f"
19+ ReadDirection = request . Query . TryGetValueCaseInsensitive ( 'd' , out var readDirection )
20+ && readDirection == "f" || readDirection == "F"
2021 ? Constants . ReadDirection . Forwards
2122 : Constants . ReadDirection . Backwards ;
2223
23- if ( ! int . TryParse ( request . Query [ "p" ] , out _fromVersionInclusive ) )
24- {
25- _fromVersionInclusive = ReadDirection == Constants . ReadDirection . Forwards
24+ _fromVersionInclusive = request . Query . TryGetValueCaseInsensitive ( 'p' , out var position )
25+ ? ( int . TryParse ( position , out _fromVersionInclusive )
26+ ? ( ReadDirection == Constants . ReadDirection . Forwards
27+ ? ( _fromVersionInclusive < StreamVersion . Start
28+ ? StreamVersion . Start
29+ : _fromVersionInclusive )
30+ : ( _fromVersionInclusive < StreamVersion . End
31+ ? StreamVersion . End
32+ : _fromVersionInclusive ) )
33+ : ( ReadDirection == Constants . ReadDirection . Forwards
34+ ? StreamVersion . Start
35+ : StreamVersion . End ) )
36+ : ( ReadDirection == Constants . ReadDirection . Forwards
2637 ? StreamVersion . Start
27- : StreamVersion . End ;
28- }
38+ : StreamVersion . End ) ;
2939
30- if ( ! int . TryParse ( request . Query [ "m" ] , out _maxCount ) )
31- {
32- _maxCount = Constants . MaxCount ;
33- }
40+ _maxCount = request . Query . TryGetValueCaseInsensitive ( 'm' , out var maxCount )
41+ ? ( int . TryParse ( maxCount , out _maxCount )
42+ ? ( _maxCount <= 0
43+ ? Constants . MaxCount
44+ : _maxCount )
45+ : Constants . MaxCount )
46+ : Constants . MaxCount ;
3447
3548 Self = ReadDirection == Constants . ReadDirection . Forwards
3649 ? LinkFormatter . FormatForwardLink ( StreamId , MaxCount , FromVersionInclusive , EmbedPayload )
0 commit comments