Skip to content

Commit

Permalink
Support English double quotation marks for escaping (#172)
Browse files Browse the repository at this point in the history
* Support English double quotation marks
  • Loading branch information
LucaBernstein authored Jul 27, 2022
1 parent fc9b398 commit 6c9bc78
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion helpers/subcommands.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func SplitQuotedCommand(s string) (res []string) {
isEscaped = true
continue
}
if c == '"' {
if c == '"' || c == '“' {
isQuoted = !isQuoted
continue
}
Expand Down
2 changes: 2 additions & 0 deletions helpers/subcommands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ func TestSplitQuotedCommand(t *testing.T) {
helpers.TestExpectArrEq(t, helpers.SplitQuotedCommand(`/command "is quoted" non-quoted and sep`), []string{"/command", "is quoted", "non-quoted", "and", "sep"}, "")
helpers.TestExpectArrEq(t, helpers.SplitQuotedCommand(`/command hello"world"`), []string{"/command", "helloworld"}, "")
helpers.TestExpectArrEq(t, helpers.SplitQuotedCommand(`/command hello "world"`), []string{"/command", "hello", "world"}, "")
helpers.TestExpectArrEq(t, helpers.SplitQuotedCommand(`/command special “quotations“`), []string{"/command", "special", "quotations"}, "")
helpers.TestExpectArrEq(t, helpers.SplitQuotedCommand(`/command special “quotations 2"`), []string{"/command", "special", "quotations 2"}, "")
helpers.TestExpectArrEq(t, helpers.SplitQuotedCommand(`/command hello" world"`), []string{"/command", "hello world"}, "")
helpers.TestExpectArrEq(t, helpers.SplitQuotedCommand(`/command "wrongly quoted`), []string{}, "quotes opened but not closed")
helpers.TestExpectArrEq(t, helpers.SplitQuotedCommand(`/command \"correctly quoted`), []string{"/command", "\"correctly", "quoted"}, "quotes opened but not closed")
Expand Down

0 comments on commit 6c9bc78

Please sign in to comment.