Skip to content

Commit

Permalink
🐛 Replace " with quotation mark
Browse files Browse the repository at this point in the history
  • Loading branch information
mamal72 committed Nov 24, 2016
1 parent 9d6c207 commit 6121551
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
7 changes: 4 additions & 3 deletions golyrics.go
Expand Up @@ -48,8 +48,9 @@ func stripeHTMLTags(HTML string) string {
return regex.ReplaceAllString(HTML, "")
}

func fixApostrophes(text string) string {
return strings.Replace(text, "'", "'", -1)
func fixApostrophesAndQuotes(text string) string {
apostrophesFixed := strings.Replace(text, "'", "'", -1)
return strings.Replace(apostrophesFixed, """, "\"", -1)
}

func getSearchURI(query string) string {
Expand All @@ -59,7 +60,7 @@ func getSearchURI(query string) string {
func getFormattedLyrics(text string) string {
noBreaks := breakToNewLine(text)
noHTMLTags := stripeHTMLTags(noBreaks)
return fixApostrophes(noHTMLTags)
return fixApostrophesAndQuotes(noHTMLTags)
}

// SearchTrack searches for tracks
Expand Down
10 changes: 5 additions & 5 deletions golyrics_test.go
Expand Up @@ -68,7 +68,7 @@ func Test_stripeHTMLTags(t *testing.T) {
}
}

func Test_fixApostrophes(t *testing.T) {
func Test_fixApostrophesAndQuotes(t *testing.T) {
type args struct {
text string
}
Expand All @@ -78,15 +78,15 @@ func Test_fixApostrophes(t *testing.T) {
want string
}{
{
name: "test should work for apostrophes in the strings",
name: "test should work for apostrophes and quotes in the strings",
args: args{
"I'm not strong enough to stay away\nCan't run from you...",
"I'm not strong enough to stay away\nCan't run from "you"...",
},
want: "I'm not strong enough to stay away\nCan't run from you...",
want: "I'm not strong enough to stay away\nCan't run from \"you\"...",
},
}
for _, tt := range tests {
if got := fixApostrophes(tt.args.text); got != tt.want {
if got := fixApostrophesAndQuotes(tt.args.text); got != tt.want {
t.Errorf("%q. fixApostrophes() = %v, want %v", tt.name, got, tt.want)
}
}
Expand Down

0 comments on commit 6121551

Please sign in to comment.