Skip to content

Commit 48014f4

Browse files
authored
Merge pull request #668 from phadej/fix_js_function_identifiers
Fix js function identifiers
2 parents 094f28b + 77f6910 commit 48014f4

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

servant-foreign/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
0.10
2+
----
3+
4+
* Do not apply JavaScript specific mangling to the names.
5+
([#191](https://github.com/haskell-servant/servant/issues/191))
6+
17
0.7.1
28
-----
39

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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ camelCaseSpec = describe "camelCase" $ do
2020
camelCase (FunctionName ["post", "counter", "inc"])
2121
`shouldBe` "postCounterInc"
2222
camelCase (FunctionName ["get", "hyphen-ated", "counter"])
23-
`shouldBe` "getHyphenatedCounter"
23+
`shouldBe` "getHyphen-atedCounter"
24+
2425

2526
----------------------------------------------------------------------
2627

0 commit comments

Comments
 (0)