diff --git a/src/Servant/Elm/Internal/Generate.hs b/src/Servant/Elm/Internal/Generate.hs index 03d989d..5308cc6 100644 --- a/src/Servant/Elm/Internal/Generate.hs +++ b/src/Servant/Elm/Internal/Generate.hs @@ -247,7 +247,7 @@ generateElmForRequest opts request = fnName = request ^. F.reqFuncName . to (replace . F.camelCase) . to stext - replace = T.replace "-" "" . T.replace "." "" + replace = T.replace "-" "" . T.replace "." "" . T.replace " " "" typeSignature = mkTypeSignature opts request @@ -327,7 +327,7 @@ elmCaptureArg segment = "capture_" <> F.captureArg segment ^. F.argName . to (stext . replace . F.unPathSegment) where - replace = T.replace "-" "_" + replace = T.replace "-" "_" . T.replace " " "_" elmQueryArg :: F.QueryArg EType -> Doc diff --git a/test/Common.hs b/test/Common.hs index 1d3f929..b53d187 100644 --- a/test/Common.hs +++ b/test/Common.hs @@ -27,7 +27,7 @@ type TestApi = :> Capture "id" Int :> Get '[JSON] Book :<|> "books" - :> Capture "title" Text + :> Capture "title space" Text :> Get '[JSON] Book :<|> "books" :> QueryFlag "published" diff --git a/test/elm-sources/getBooksByTitleSource.elm b/test/elm-sources/getBooksByTitleSource.elm index c31e25d..01de823 100644 --- a/test/elm-sources/getBooksByTitleSource.elm +++ b/test/elm-sources/getBooksByTitleSource.elm @@ -7,8 +7,8 @@ import Json.Decode as J type alias Book = {} jsonDecBook = J.succeed {} -getBooksByTitle : String -> (Result Http.Error (Book) -> msg) -> Cmd msg -getBooksByTitle capture_title toMsg = +getBooksByTitlespace : String -> (Result Http.Error (Book) -> msg) -> Cmd msg +getBooksByTitlespace capture_title_space toMsg = let params = List.filterMap identity @@ -23,7 +23,7 @@ getBooksByTitle capture_title toMsg = , url = Url.Builder.crossOrigin "" [ "books" - , Url.percentEncode (capture_title) + , Url.percentEncode (capture_title_space) ] params , body =