cleanPath tests again

This commit is contained in:
Michael Snoyman 2012-01-05 05:46:20 +02:00
parent 1e8b15acff
commit 0a9df1076e
2 changed files with 5 additions and 1 deletions

View File

@ -169,7 +169,10 @@ toWaiApp' :: ( Yesod master
-> Maybe Key
-> W.Application
toWaiApp' y key' env =
yesodDispatch y y id app404 handler405 method (W.pathInfo env) key' env
case cleanPath y $ W.pathInfo env of
Left pieces -> sendRedirect y pieces env
Right pieces ->
yesodDispatch y y id app404 handler405 method pieces key' env
where
app404 = yesodRunner notFound y y Nothing id
handler405 route = yesodRunner badMethod y y (Just route) id

View File

@ -42,6 +42,7 @@ mkYesod "Y" [parseRoutes|
instance Yesod Y where
approot _ = "http://test"
cleanPath _ s@("subsite":_) = Right s
cleanPath _ ["bar", ""] = Right ["bar"]
cleanPath _ ["bar"] = Left ["bar", ""]
cleanPath _ s =