From 0a9df1076e8a9cb72cc86287e806aa250f3f95ee Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Thu, 5 Jan 2012 05:46:20 +0200 Subject: [PATCH] cleanPath tests again --- yesod-core/Yesod/Dispatch.hs | 5 ++++- yesod-core/test/YesodCoreTest/CleanPath.hs | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) 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 =