Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-10-29 18:22:35 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-10-30 11:41:04 +0300
commit8a1c637c4494751046142e0ef345fce38fc1431b (patch)
tree43847875b05e6261ca204c3c565fc84db7f63bde /common
parent6d95dc9d74681cba53b46e79c6e1d58d27fcdfb0 (diff)
Fix setting HUGO_MODULE_PROXY etc. via env vars
Fixes #7903
Diffstat (limited to 'common')
-rw-r--r--common/maps/params.go4
-rw-r--r--common/maps/params_test.go24
2 files changed, 28 insertions, 0 deletions
diff --git a/common/maps/params.go b/common/maps/params.go
index ecb63d7a5..1f0856598 100644
--- a/common/maps/params.go
+++ b/common/maps/params.go
@@ -37,7 +37,11 @@ func getNested(m map[string]interface{}, indices []string) (interface{}, string,
first := indices[0]
v, found := m[strings.ToLower(cast.ToString(first))]
if !found {
+ if len(indices) == 1 {
+ return nil, first, m
+ }
return nil, "", nil
+
}
if len(indices) == 1 {
diff --git a/common/maps/params_test.go b/common/maps/params_test.go
index 8016a8bd6..46d672d87 100644
--- a/common/maps/params_test.go
+++ b/common/maps/params_test.go
@@ -47,5 +47,29 @@ func TestGetNestedParam(t *testing.T) {
c.Assert(must("nested_color", "_", m), qt.Equals, "blue")
c.Assert(must("nested.nestednested.color", ".", m), qt.Equals, "green")
c.Assert(must("string.name", ".", m), qt.IsNil)
+ c.Assert(must("nested.foo", ".", m), qt.IsNil)
+
+}
+
+// https://github.com/gohugoio/hugo/issues/7903
+func TestGetNestedParamFnNestedNewKey(t *testing.T) {
+
+ c := qt.New(t)
+
+ nested := map[string]interface{}{
+ "color": "blue",
+ }
+ m := map[string]interface{}{
+ "nested": nested,
+ }
+
+ existing, nestedKey, owner, err := GetNestedParamFn("nested.new", ".", func(key string) interface{} {
+ return m[key]
+ })
+
+ c.Assert(err, qt.IsNil)
+ c.Assert(existing, qt.IsNil)
+ c.Assert(nestedKey, qt.Equals, "new")
+ c.Assert(owner, qt.DeepEquals, nested)
}