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
|
0.7.1
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ snakeCase :: FunctionName -> Text
|
||||||
snakeCase = view snakeCaseL
|
snakeCase = view snakeCaseL
|
||||||
|
|
||||||
camelCaseL :: Getter FunctionName Text
|
camelCaseL :: Getter FunctionName Text
|
||||||
camelCaseL = _FunctionName . to (convert . map (replace "-" ""))
|
camelCaseL = _FunctionName . to convert
|
||||||
where
|
where
|
||||||
convert [] = ""
|
convert [] = ""
|
||||||
convert (p:ps) = mconcat $ p : map capitalize ps
|
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))]
|
req & reqUrl . path <>~ [Segment (Static (PathSegment str))]
|
||||||
& reqFuncName . _FunctionName %~ (++ [str])
|
& reqFuncName . _FunctionName %~ (++ [str])
|
||||||
where
|
where
|
||||||
str =
|
str = pack . symbolVal $ (Proxy :: Proxy path)
|
||||||
Data.Text.map (\c -> if c == '.' then '_' else c)
|
|
||||||
. pack . symbolVal $ (Proxy :: Proxy path)
|
|
||||||
|
|
||||||
instance HasForeign lang ftype api
|
instance HasForeign lang ftype api
|
||||||
=> HasForeign lang ftype (RemoteHost :> api) where
|
=> HasForeign lang ftype (RemoteHost :> api) where
|
||||||
|
|
|
@ -20,7 +20,8 @@ camelCaseSpec = describe "camelCase" $ do
|
||||||
camelCase (FunctionName ["post", "counter", "inc"])
|
camelCase (FunctionName ["post", "counter", "inc"])
|
||||||
`shouldBe` "postCounterInc"
|
`shouldBe` "postCounterInc"
|
||||||
camelCase (FunctionName ["get", "hyphen-ated", "counter"])
|
camelCase (FunctionName ["get", "hyphen-ated", "counter"])
|
||||||
`shouldBe` "getHyphenatedCounter"
|
`shouldBe` "getHyphen-atedCounter"
|
||||||
|
|
||||||
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue