diff --git a/Text/Inflections/Parse/CamelCase.hs b/Text/Inflections/Parse/CamelCase.hs index 9586695..6ef5571 100644 --- a/Text/Inflections/Parse/CamelCase.hs +++ b/Text/Inflections/Parse/CamelCase.hs @@ -51,6 +51,6 @@ parser acronyms = many (acronym acronyms <|> word) <* eof word :: Parser Word word = do firstChar <- upperChar <|> lowerChar - restChars <- many lowerChar + restChars <- many $ lowerChar <|> digitChar return . Word . T.pack $ firstChar : restChars {-# INLINE word #-} diff --git a/test/Text/InflectionsSpec.hs b/test/Text/InflectionsSpec.hs index 5f10fe3..e95a796 100644 --- a/test/Text/InflectionsSpec.hs +++ b/test/Text/InflectionsSpec.hs @@ -7,9 +7,11 @@ import Text.Inflections (toUnderscore, toDashed, toCamelCased) spec :: Spec spec = do - describe "toUnderscore" $ + describe "toUnderscore" $ do it "converts camel case to snake case" $ toUnderscore "camelCasedText" `shouldReturn` "camel_cased_text" + it "converts camel case to snake case with numbers" $ + toUnderscore "ipv4Address" `shouldReturn` "ipv4_address" describe "toDashed" $ it "converts camel case to dashed" $ toDashed "camelCasedText" `shouldReturn` "camel-cased-text"