Skip to content

Commit c20c094

Browse files
berdariophadej
authored andcommitted
Fix javascript function name generation, mostly fixes #191
and remove js-specific code in servant-foreign (code which would now be dead)
1 parent 094f28b commit c20c094

File tree

3 files changed

+2
-6
lines changed

3 files changed

+2
-6
lines changed

servant-foreign/src/Servant/Foreign/Inflections.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ snakeCase :: FunctionName -> Text
3232
snakeCase = view snakeCaseL
3333

3434
camelCaseL :: Getter FunctionName Text
35-
camelCaseL = _FunctionName . to (convert . map (replace "-" ""))
35+
camelCaseL = _FunctionName . to convert
3636
where
3737
convert [] = ""
3838
convert (p:ps) = mconcat $ p : map capitalize ps

servant-foreign/src/Servant/Foreign/Internal.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,7 @@ instance (KnownSymbol path, HasForeign lang ftype api)
316316
req & reqUrl . path <>~ [Segment (Static (PathSegment str))]
317317
& reqFuncName . _FunctionName %~ (++ [str])
318318
where
319-
str =
320-
Data.Text.map (\c -> if c == '.' then '_' else c)
321-
. pack . symbolVal $ (Proxy :: Proxy path)
319+
str = pack . symbolVal $ (Proxy :: Proxy path)
322320

323321
instance HasForeign lang ftype api
324322
=> HasForeign lang ftype (RemoteHost :> api) where

servant-foreign/test/Servant/ForeignSpec.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ camelCaseSpec = describe "camelCase" $ do
1919
it "converts FunctionNames to camelCase" $ do
2020
camelCase (FunctionName ["post", "counter", "inc"])
2121
`shouldBe` "postCounterInc"
22-
camelCase (FunctionName ["get", "hyphen-ated", "counter"])
23-
`shouldBe` "getHyphenatedCounter"
2422

2523
----------------------------------------------------------------------
2624

0 commit comments

Comments
 (0)