From c20c09411df06596592def6f9612c1bdf0be398c Mon Sep 17 00:00:00 2001 From: Dario Bertini Date: Sun, 24 Jul 2016 15:46:55 +0200 Subject: [PATCH] Fix javascript function name generation, mostly fixes #191 and remove js-specific code in servant-foreign (code which would now be dead) --- servant-foreign/src/Servant/Foreign/Inflections.hs | 2 +- servant-foreign/src/Servant/Foreign/Internal.hs | 4 +--- servant-foreign/test/Servant/ForeignSpec.hs | 2 -- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/servant-foreign/src/Servant/Foreign/Inflections.hs b/servant-foreign/src/Servant/Foreign/Inflections.hs index 759d04a0..4c0140a8 100644 --- a/servant-foreign/src/Servant/Foreign/Inflections.hs +++ b/servant-foreign/src/Servant/Foreign/Inflections.hs @@ -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 diff --git a/servant-foreign/src/Servant/Foreign/Internal.hs b/servant-foreign/src/Servant/Foreign/Internal.hs index 59d09436..3eced051 100644 --- a/servant-foreign/src/Servant/Foreign/Internal.hs +++ b/servant-foreign/src/Servant/Foreign/Internal.hs @@ -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 diff --git a/servant-foreign/test/Servant/ForeignSpec.hs b/servant-foreign/test/Servant/ForeignSpec.hs index 966861d5..d98e640f 100644 --- a/servant-foreign/test/Servant/ForeignSpec.hs +++ b/servant-foreign/test/Servant/ForeignSpec.hs @@ -19,8 +19,6 @@ camelCaseSpec = describe "camelCase" $ do it "converts FunctionNames to camelCase" $ do camelCase (FunctionName ["post", "counter", "inc"]) `shouldBe` "postCounterInc" - camelCase (FunctionName ["get", "hyphen-ated", "counter"]) - `shouldBe` "getHyphenatedCounter" ----------------------------------------------------------------------