diff --git a/yesod-core/Yesod/Dispatch.hs b/yesod-core/Yesod/Dispatch.hs index a1c8691e..45ac2cbe 100644 --- a/yesod-core/Yesod/Dispatch.hs +++ b/yesod-core/Yesod/Dispatch.hs @@ -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 diff --git a/yesod-core/test/YesodCoreTest/CleanPath.hs b/yesod-core/test/YesodCoreTest/CleanPath.hs index 83999b4a..0428164e 100644 --- a/yesod-core/test/YesodCoreTest/CleanPath.hs +++ b/yesod-core/test/YesodCoreTest/CleanPath.hs @@ -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 =