git.iko.soy/haskell-servant/servant-elm
on master help sign in
handle spaces
commite26ae721938d63490e6d831d1e6b147595da96a2 authorDomen Kožar <domen@dev.si> dateThu 4 Jan 2024, 14:26 (3 years ago) parent1248730
3 files changed+6−6
src/Servant/Elm/Internal/Generate.hs+2−2 test/Common.hs+1−1 test/elm-sources/getBooksByTitleSource.elm+3−3
src/Servant/Elm/Internal/Generate.hs+2−2
@@ -247,7 +247,7 @@ generateElmForRequest opts request =
247247 fnName =
248248 request ^. F.reqFuncName . to (replace . F.camelCase) . to stext
249249
250− replace = T.replace "-" "" . T.replace "." ""
250+ replace = T.replace "-" "" . T.replace "." "" . T.replace " " ""
251251
252252 typeSignature =
253253 mkTypeSignature opts request
@@ -327,7 +327,7 @@ elmCaptureArg segment =
327327 "capture_" <>
328328 F.captureArg segment ^. F.argName . to (stext . replace . F.unPathSegment)
329329 where
330− replace = T.replace "-" "_"
330+ replace = T.replace "-" "_" . T.replace " " "_"
331331
332332
333333elmQueryArg :: F.QueryArg EType -> Doc
test/Common.hs+1−1
@@ -27,7 +27,7 @@ type TestApi =
2727 :> Capture "id" Int
2828 :> Get '[JSON] Book
2929 :<|> "books"
30− :> Capture "title" Text
30+ :> Capture "title space" Text
3131 :> Get '[JSON] Book
3232 :<|> "books"
3333 :> QueryFlag "published"
test/elm-sources/getBooksByTitleSource.elm+3−3
@@ -7,8 +7,8 @@ import Json.Decode as J
77type alias Book = {}
88jsonDecBook = J.succeed {}
99
10−getBooksByTitle : String -> (Result Http.Error (Book) -> msg) -> Cmd msg
11−getBooksByTitle capture_title toMsg =
10+getBooksByTitlespace : String -> (Result Http.Error (Book) -> msg) -> Cmd msg
11+getBooksByTitlespace capture_title_space toMsg =
1212 let
1313 params =
1414 List.filterMap identity
@@ -23,7 +23,7 @@ getBooksByTitle capture_title toMsg =
2323 , url =
2424 Url.Builder.crossOrigin ""
2525 [ "books"
26− , Url.percentEncode (capture_title)
26+ , Url.percentEncode (capture_title_space)
2727 ]
2828 params
2929 , body =