Encode empty paths correctly #730

This commit is contained in:
Michael Snoyman 2014-05-06 08:25:33 +03:00
parent cbbeb3b7f6
commit 60526676e5
3 changed files with 24 additions and 2 deletions

View File

@ -539,7 +539,9 @@ request reqBuilder = do
, rbdGets = []
, rbdHeaders = []
}
let path = TE.decodeUtf8 $ Builder.toByteString $ H.encodePathSegments rbdPath
let path
| null rbdPath = "/"
| otherwise = TE.decodeUtf8 $ Builder.toByteString $ H.encodePathSegments rbdPath
-- expire cookies and filter them for the current path. TODO: support max age
currentUtc <- liftIO getCurrentTime

View File

@ -15,6 +15,7 @@ import Data.Text (Text)
import Data.Monoid ((<>))
import Control.Applicative
import Network.Wai (pathInfo)
import Data.Maybe (fromMaybe)
import Data.ByteString.Lazy.Char8 ()
import qualified Data.Map as Map
@ -122,6 +123,16 @@ main = hspec $ do
get ("/dynamic2/שלום" :: Text)
statusIs 200
bodyEquals "שלום"
describe "cookies" $ yesodSpec cookieApp $ do
yit "should send the cookie #730" $ do
get ("/" :: Text)
statusIs 200
post ("/cookie/foo" :: Text)
statusIs 302
get ("/" :: Text)
statusIs 200
printBody
bodyContains "Foo"
instance RenderMessage LiteApp FormMessage where
renderMessage _ _ = defaultFormMessage
@ -151,3 +162,12 @@ app = liteApp $ do
case mfoo of
FormSuccess (foo, _) -> return $ toHtml foo
_ -> defaultLayout widget
cookieApp :: LiteApp
cookieApp = liteApp $ do
dispatchTo $ fromMaybe "no message available" <$> getMessage
onStatic "cookie" $ do
onStatic "foo" $ dispatchTo $ do
setMessage "Foo"
redirect ("/cookie/home" :: Text)
return ()

View File

@ -1,5 +1,5 @@
name: yesod-test
version: 1.2.1.4
version: 1.2.1.5
license: MIT
license-file: LICENSE
author: Nubis <nubis@woobiz.com.ar>