mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
e971b7d866
commit
42f37b4e98
2 changed files with 4 additions and 1 deletions
|
@ -112,9 +112,10 @@ func (ns *Namespace) Unmarshal(args ...any) (any, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("type %T not supported", data)
|
return nil, fmt.Errorf("type %T not supported", data)
|
||||||
}
|
}
|
||||||
|
dataStr = strings.TrimSpace(dataStr)
|
||||||
|
|
||||||
if dataStr == "" {
|
if dataStr == "" {
|
||||||
return nil, errors.New("no data to transform")
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
key := hashing.MD5FromStringHexEncoded(dataStr)
|
key := hashing.MD5FromStringHexEncoded(dataStr)
|
||||||
|
|
|
@ -139,6 +139,8 @@ func TestUnmarshal(t *testing.T) {
|
||||||
a;b;c`, mime: media.Builtin.CSVType}, map[string]any{"DElimiter": ";", "Comment": "%"}, func(r [][]string) {
|
a;b;c`, mime: media.Builtin.CSVType}, map[string]any{"DElimiter": ";", "Comment": "%"}, func(r [][]string) {
|
||||||
b.Assert([][]string{{"a", "b", "c"}}, qt.DeepEquals, r)
|
b.Assert([][]string{{"a", "b", "c"}}, qt.DeepEquals, r)
|
||||||
}},
|
}},
|
||||||
|
{``, nil, nil},
|
||||||
|
{` `, nil, nil},
|
||||||
// errors
|
// errors
|
||||||
{"thisisnotavaliddataformat", nil, false},
|
{"thisisnotavaliddataformat", nil, false},
|
||||||
{testContentResource{key: "r1", content: `invalid&toml"`, mime: media.Builtin.TOMLType}, nil, false},
|
{testContentResource{key: "r1", content: `invalid&toml"`, mime: media.Builtin.TOMLType}, nil, false},
|
||||||
|
|
Loading…
Reference in a new issue