joinPath takes Text

This commit is contained in:
Michael Snoyman 2011-04-15 07:33:52 +03:00
parent 69abcb344a
commit 18e04175eb
2 changed files with 4 additions and 6 deletions

View File

@ -206,11 +206,11 @@ class RenderRoute (Route a) => Yesod a where
-- | Join the pieces of a path together into an absolute URL. This should
-- be the inverse of 'splitPath'.
joinPath :: a
-> Builder -- ^ application root
-> TS.Text -- ^ application root
-> [TS.Text] -- ^ path pieces
-> [(TS.Text, TS.Text)] -- ^ query string
-> Builder
joinPath _ ar pieces' qs' = ar `mappend` encodePath pieces qs
joinPath _ ar pieces' qs' = fromText ar `mappend` encodePath pieces qs
where
pieces = if null pieces' then [""] else pieces'
qs = map (TE.encodeUtf8 *** go) qs'
@ -569,7 +569,7 @@ yesodRender :: Yesod y
yesodRender y u qs =
TE.decodeUtf8 $ toByteString $
fromMaybe
(joinPath y (fromText $ approot y) ps
(joinPath y (approot y) ps
$ qs ++ qs')
(urlRenderOverride y u)
where

View File

@ -23,8 +23,6 @@ import Network.HTTP.Types (status301)
import Data.Text (Text)
import Data.Monoid (mappend)
import qualified Blaze.ByteString.Builder
import qualified Blaze.ByteString.Builder.Char8
import Blaze.ByteString.Builder.Char.Utf8 (fromText)
import qualified Data.ByteString.Char8 as S8
{-|
@ -87,7 +85,7 @@ sendRedirect y segments' env =
, ("Location", Blaze.ByteString.Builder.toByteString dest')
] "Redirecting"
where
dest = joinPath y (fromText $ approot y) segments' []
dest = joinPath y (approot y) segments' []
dest' =
if S.null (W.rawQueryString env)
then dest