Skip to content

Commit

Permalink
handle spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
domenkozar committed Jan 4, 2024
1 parent 1248730 commit e26ae72
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Servant/Elm/Internal/Generate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions test/elm-sources/getBooksByTitleSource.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,7 +23,7 @@ getBooksByTitle capture_title toMsg =
, url =
Url.Builder.crossOrigin ""
[ "books"
, Url.percentEncode (capture_title)
, Url.percentEncode (capture_title_space)
]
params
, body =
Expand Down

0 comments on commit e26ae72

Please sign in to comment.