Merge pull request #668 from phadej/fix_js_function_identifiers
Fix js function identifiers
This commit is contained in:
commit
48014f4a66
4 changed files with 10 additions and 5 deletions
|
@ -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
|
||||
-----
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
|
|
Loading…
Reference in a new issue