diff --git a/internal/esbuild/util.go b/internal/esbuild/util.go index b9d4ef53..6d828953 100644 --- a/internal/esbuild/util.go +++ b/internal/esbuild/util.go @@ -12,5 +12,10 @@ func ToKebabCase(str string) string { converted := matchLetter.ReplaceAllStringFunc(str, func(match string) string { return "-" + strings.ToLower(match) }) - return converted[1:] + + if strings.HasPrefix(converted, "-") { + converted = converted[1:] + } + + return converted } diff --git a/internal/esbuild/util_test.go b/internal/esbuild/util_test.go index 2edcb6cd..785a056e 100644 --- a/internal/esbuild/util_test.go +++ b/internal/esbuild/util_test.go @@ -12,4 +12,6 @@ func TestKebabCase(t *testing.T) { assert.Equal(t, "frosh-tools", ToKebabCase("FroshTools")) assert.Equal(t, "my-module-name-s-w6", ToKebabCase("MyModuleNameSW6")) assert.Equal(t, "a-i-search", ToKebabCase("AISearch")) + assert.Equal(t, "mediameets-fb-pixel", ToKebabCase("mediameetsFbPixel")) + assert.Equal(t, "wwbla-bar-foo", ToKebabCase("wwblaBarFoo")) }