diff --git a/CHANGELOG.md b/CHANGELOG.md index 886e386d4..842c511ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Thank you! * Fixes a regression from 0.18.4 which incorrectly rendered default values for certain types (see [#1593](https://github.com/disneystreaming/smithy4s/pull/1593)) * Fixes an issue in which union members targetting Unit would fail to compile when used as traits (see [#1600](https://github.com/disneystreaming/smithy4s/pull/1600)). * Make the `transform` method in generated `*Gen` algebras final. This should make it possible to derive e.g. `FunctorK` instances in cats-tagless automatically (see [#1588](https://github.com/disneystreaming/smithy4s/pull/1588)). +* Fixes commons.toKebabCase() sometimes drops the first letter (see [#1603](https://github.com/disneystreaming/smithy4s/pull/1603)). # 0.18.24 diff --git a/modules/decline/src/core/commons.scala b/modules/decline/src/core/commons.scala index af83d7bd4..8bc83a423 100644 --- a/modules/decline/src/core/commons.scala +++ b/modules/decline/src/core/commons.scala @@ -28,7 +28,7 @@ import java.util.Base64 object commons { def toKebabCase(s: String): String = - s.replaceAll("([A-Z])", "-$1").toLowerCase.drop(1) + s.replaceAll("([A-Z])", "-$1").toLowerCase.stripPrefix("-") implicit def covariantAnyFunctor[F[_]](implicit ev: MonadError[F, ConstraintError] diff --git a/modules/decline/test/src/smithy4s/decline/core/CommonsSpec.scala b/modules/decline/test/src/smithy4s/decline/core/CommonsSpec.scala new file mode 100644 index 000000000..49ed79034 --- /dev/null +++ b/modules/decline/test/src/smithy4s/decline/core/CommonsSpec.scala @@ -0,0 +1,18 @@ +package smithy4s.decline.core + +import weaver._ + +object CommonsSpec extends FunSuite { + + test("toKebabCase base case") { + expect( + commons.toKebabCase("StartsWithUpperCase") == "starts-with-upper-case" + ) + } + + test("toKebabCase starts with lower case") { + expect( + commons.toKebabCase("startsWithLowerCase") == "starts-with-lower-case" + ) + } +}