From 2d76a6e7715cd127326aaddd5d69bfe97b6bead2 Mon Sep 17 00:00:00 2001 From: M Farkas-Dyck Date: Thu, 20 Jul 2017 12:50:37 -0800 Subject: [PATCH] Prepend trailing slash to empty request path --- servant-client/src/Servant/Common/Req.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/servant-client/src/Servant/Common/Req.hs b/servant-client/src/Servant/Common/Req.hs index 88d1d001..0168b8e1 100644 --- a/servant-client/src/Servant/Common/Req.hs +++ b/servant-client/src/Servant/Common/Req.hs @@ -29,6 +29,7 @@ import Control.Monad.Reader import Control.Monad.Trans.Control (MonadBaseControl (..)) import qualified Data.ByteString.Builder as BS import Data.ByteString.Lazy hiding (pack, filter, map, null, elem, any) +import qualified Data.ByteString.Lazy as BS import Data.String import Data.String.Conversions (cs) import Data.Proxy @@ -162,7 +163,9 @@ reqToRequest req (BaseUrl reqScheme reqHost reqPort path) = } , uriPath = fullPath } - fullPath = path ++ cs (BS.toLazyByteString (reqPath req)) + fullPath = path ++ cs (slashIfNull $ BS.toLazyByteString (reqPath req)) + where slashIfNull s | BS.null s = "/" + | otherwise = s setrqb r = case reqBody req of Nothing -> r