Fix sep:"none" and mapsep:"none"

According to the README.md, a value of `"none"` for the `sep` tag (for
slices) and `mapsep` (for maps) is meant to disable the separator that
would allow multiple entries to be added from a single argument.
However, using `"none"` just set the separator to the rune `'n'`.

Fix the parsing of the tag, and also update `SplitEscaped` to not split
with a separator of `-1`.

Add a new test for the new cases.
This commit is contained in:
Cam Hutchison
2020-06-01 22:27:02 +10:00
committed by Alec Thomas
parent b11ebc500b
commit b89354adb0
3 changed files with 26 additions and 10 deletions
+3
View File
@@ -636,6 +636,9 @@ func urlMapper() MapperFunc {
//
// SplitEscaped(`hello\,there,bob`, ',') == []string{"hello,there", "bob"}
func SplitEscaped(s string, sep rune) (out []string) {
if sep == -1 {
return []string{s}
}
escaped := false
token := ""
for _, ch := range s {