Skip to content

Commit

Permalink
fix: js plugin name normalization, fixes #285
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Jan 9, 2024
1 parent a998a88 commit 890d268
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/esbuild/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "-") {

Check failure on line 16 in internal/esbuild/util.go

View workflow job for this annotation

GitHub Actions / lint

S1017: should replace this `if` statement with an unconditional `strings.TrimPrefix` (gosimple)
converted = converted[1:]
}

return converted
}
2 changes: 2 additions & 0 deletions internal/esbuild/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}

0 comments on commit 890d268

Please sign in to comment.