Skip to content

Commit

Permalink
Closes #1539 kebab caseificiation (#1603)
Browse files Browse the repository at this point in the history
* Strip any leading - but no other character when converting from case camel case to kebab case. Fixes 1539
  • Loading branch information
dwalend authored Oct 1, 2024
1 parent 854db35 commit 85cf6a0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion modules/decline/src/core/commons.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
18 changes: 18 additions & 0 deletions modules/decline/test/src/smithy4s/decline/core/CommonsSpec.scala
Original file line number Diff line number Diff line change
@@ -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"
)
}
}

0 comments on commit 85cf6a0

Please sign in to comment.