diff --git a/src/Yesod/Paginator/Widgets.hs b/src/Yesod/Paginator/Widgets.hs index 7c97088..4003a3f 100644 --- a/src/Yesod/Paginator/Widgets.hs +++ b/src/Yesod/Paginator/Widgets.hs @@ -178,10 +178,12 @@ getUpdateGetParams getUpdateGetParams pageParamName = do params <- handlerToWidget $ reqGetParams <$> getRequest pure - $ \number -> - nubOn fst - $ [(unPageParamName pageParamName, tshow number)] - <> params + $ \number -> formatParams number params + where + formatParams :: Show a => a -> [(Text, Text)] -> [(Text, Text)] + formatParams number params = + let name = unPageParamName pageParamName + in [(name, tshow number)] <> filter ((/=) name . fst) params renderGetParams :: [(Text, Text)] -> Text renderGetParams [] = "" diff --git a/test/Yesod/Paginator/WidgetsSpec.hs b/test/Yesod/Paginator/WidgetsSpec.hs index e8afb6f..9b27ba6 100644 --- a/test/Yesod/Paginator/WidgetsSpec.hs +++ b/test/Yesod/Paginator/WidgetsSpec.hs @@ -8,7 +8,8 @@ import SpecHelper spec :: Spec spec = withApp $ do - describe "simple" $ it "works" $ do + describe "simple" $ do + it "works" $ do get $ SimpleR 10 3 3 statusIs 200 @@ -52,6 +53,27 @@ spec = withApp $ do , "" ] + it "includes all parameters with the same name" $ do + get $ SimpleR 10 3 3 + + request $ do + addGetParam "p" "3" + addGetParam "ids[]" "1" + addGetParam "ids[]" "2" + setUrl $ SimpleR 10 3 3 + + statusIs 200 + + bodyContains $ concat + [ "" + ] + describe "ellipsed" $ it "works" $ do get $ EllipsedR 10 3 3