Skip to content

Commit

Permalink
fix: single letter words resolves #39
Browse files Browse the repository at this point in the history
  • Loading branch information
tympanix committed Jun 18, 2018
1 parent 6e5aab7 commit 84bde13
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions parse/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func Filename(filename string) string {
return strings.TrimSuffix(f, filepath.Ext(f))
}

var abbreviationRegexp = regexp.MustCompile(`[A-Z]\s[A-Z](\s[A-Z])*`)
var abbreviationRegexp = regexp.MustCompile(`[A-Z]\s[A-Z](\s[A-Z])*\s`)
var illegalcharsRegexp = regexp.MustCompile(`[^\p{L}0-9\s&'_\(\)-]`)
var spaceReplaceRegexp = regexp.MustCompile(`[\.\s_]+`)

Expand All @@ -63,7 +63,7 @@ func CleanName(name string) string {
name = illegalcharsRegexp.ReplaceAllString(name, "")

name = abbreviationRegexp.ReplaceAllStringFunc(name, func(match string) string {
return strings.Replace(match, " ", "", -1)
return strings.Replace(match, " ", "", -1) + " "
})

return strings.TrimSpace(name)
Expand Down
2 changes: 2 additions & 0 deletions parse/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ func TestCleanName(t *testing.T) {
assert.Equal(t, "this is a (test)", CleanName("this?_=is#.,a_(test)"))
assert.Equal(t, "abc ABC abc", CleanName("abc.A.B.C.abc"))
assert.Equal(t, "abc ABC abc", CleanName("abc A B C abc"))
assert.Equal(t, "A Good Day To Die Hard", CleanName("A.Good.Day.To.Die.Hard"))
assert.Equal(t, "This Is A Test", CleanName("This.Is.A.Test"))
}

func TestFileName(t *testing.T) {
Expand Down

0 comments on commit 84bde13

Please sign in to comment.