File tree 2 files changed +11
-3
lines changed
2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -118,8 +118,12 @@ param key = Match \route ->
118
118
case M .lookup key map of
119
119
Nothing ->
120
120
invalid $ free $ KeyNotFound key
121
- Just el ->
122
- pure $ Tuple (Cons (Query <<< M .delete key $ map) rs) el
121
+ Just el -> do
122
+ let remainingParams = M .delete key map
123
+ pure $
124
+ if M .isEmpty remainingParams
125
+ then Tuple rs el
126
+ else Tuple (Cons (Query remainingParams) rs) el
123
127
_ ->
124
128
invalid $ free ExpectedQuery
125
129
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ instance showMyRoutes :: Show MyRoutes where show = genericShow
35
35
routing :: Match MyRoutes
36
36
routing = oneOf
37
37
[ Foo <$> (lit " foo" *> num) <*> params
38
- , Bar <$> (lit " bar" *> bool) <*> (param " baz" )
38
+ , Bar <$> (lit " bar" *> bool) <*> (param " baz" ) <* end
39
39
, Baz <$> (lit " list" *> list num)
40
40
, Quux <$> (lit " " *> lit " quux" *> int)
41
41
, Corge <$> (lit " corge" *> str)
@@ -57,6 +57,10 @@ main = do
57
57
{ actual: match routing " bar/true?baz=test"
58
58
, expected: Right (Bar true " test" )
59
59
}
60
+ assertEqual
61
+ { actual: lmap (const unit) (match routing " bar/true?baz=test&oof=true" )
62
+ , expected: Left unit
63
+ }
60
64
assertEqual
61
65
{ actual: match routing " bar/false?baz=%D0%B2%D1%80%D0%B5%D0%BC%D0%B5%D0%BD%D0%BD%D1%8B%D0%B9%20%D1%84%D0%B0%D0%B9%D0%BB"
62
66
, expected: Right (Bar false " временный файл" )
You can’t perform that action at this time.
0 commit comments