Merge pull request #668 from phadej/fix_js_function_identifiers

Fix js function identifiers
This commit is contained in:
Oleg Grenrus 2017-01-16 12:15:35 +02:00 committed by GitHub
commit 48014f4a66
4 changed files with 10 additions and 5 deletions

View File

@ -1,3 +1,9 @@
0.10
----
* Do not apply JavaScript specific mangling to the names.
([#191](https://github.com/haskell-servant/servant/issues/191))
0.7.1
-----

View File

@ -32,7 +32,7 @@ snakeCase :: FunctionName -> Text
snakeCase = view snakeCaseL
camelCaseL :: Getter FunctionName Text
camelCaseL = _FunctionName . to (convert . map (replace "-" ""))
camelCaseL = _FunctionName . to convert
where
convert [] = ""
convert (p:ps) = mconcat $ p : map capitalize ps

View File

@ -316,9 +316,7 @@ instance (KnownSymbol path, HasForeign lang ftype api)
req & reqUrl . path <>~ [Segment (Static (PathSegment str))]
& reqFuncName . _FunctionName %~ (++ [str])
where
str =
Data.Text.map (\c -> if c == '.' then '_' else c)
. pack . symbolVal $ (Proxy :: Proxy path)
str = pack . symbolVal $ (Proxy :: Proxy path)
instance HasForeign lang ftype api
=> HasForeign lang ftype (RemoteHost :> api) where

View File

@ -20,7 +20,8 @@ camelCaseSpec = describe "camelCase" $ do
camelCase (FunctionName ["post", "counter", "inc"])
`shouldBe` "postCounterInc"
camelCase (FunctionName ["get", "hyphen-ated", "counter"])
`shouldBe` "getHyphenatedCounter"
`shouldBe` "getHyphen-atedCounter"
----------------------------------------------------------------------