redirect uses redirectParams
This commit is contained in:
parent
0652fae94f
commit
5bed76f067
@ -255,16 +255,15 @@ safeEh er = YesodApp $ \_ _ _ -> do
|
|||||||
|
|
||||||
-- | Redirect to the given route.
|
-- | Redirect to the given route.
|
||||||
redirect :: RedirectType -> Routes master -> GHandler sub master a
|
redirect :: RedirectType -> Routes master -> GHandler sub master a
|
||||||
redirect rt url = do
|
redirect rt url = redirectParams rt url []
|
||||||
r <- getUrlRender
|
|
||||||
redirectString rt $ r url
|
|
||||||
|
|
||||||
-- | Redirects to the given route with the associated query-string parameters.
|
-- | Redirects to the given route with the associated query-string parameters.
|
||||||
redirectParams :: RedirectType -> Routes master -> [(String, String)]
|
redirectParams :: RedirectType -> Routes master -> [(String, String)]
|
||||||
-> GHandler sub master a
|
-> GHandler sub master a
|
||||||
redirectParams rt url params = do
|
redirectParams rt url params = do
|
||||||
r <- getUrlRender
|
r <- getUrlRender
|
||||||
redirectString rt $ r url ++ '?' : encodeUrlPairs params
|
redirectString rt $ r url ++
|
||||||
|
if null params then "" else '?' : encodeUrlPairs params
|
||||||
where
|
where
|
||||||
encodeUrlPairs = intercalate "&" . map encodeUrlPair
|
encodeUrlPairs = intercalate "&" . map encodeUrlPair
|
||||||
encodeUrlPair (x, []) = escape x
|
encodeUrlPair (x, []) = escape x
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user