Skip to content

Commit

Permalink
added fix for zero length alias
Browse files Browse the repository at this point in the history
  • Loading branch information
dave committed Aug 28, 2020
1 parent 1283a2e commit 2abe0ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions jen/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,5 +247,10 @@ func guessAlias(path string) string {
alias = alias[runeLen:]
}

// If path part was all digits, we may be left with an empty string. In this case use "pkg" as the alias.
if alias == "" {
alias = "pkg"
}

return alias
}
1 change: 1 addition & 0 deletions jen/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func TestGuessAlias(t *testing.T) {
"a/foo-go": "foogo",
"123a": "a",
"a/321a.b": "ab",
"a/123": "pkg",
}
for path, expected := range data {
if guessAlias(path) != expected {
Expand Down

0 comments on commit 2abe0ee

Please sign in to comment.