mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-11 20:03:58 +02:00
Fix case issue Viper vs Blackfriday config
There are still work to be done in the case department, but that will have to be another day. Fixes #2581 See https://github.com/spf13/viper/issues/261
This commit is contained in:
committed by
GitHub
parent
4d6cd3cb2a
commit
40b1b8f703
@@ -119,6 +119,29 @@ func ReaderToBytes(lines io.Reader) []byte {
|
||||
return bc
|
||||
}
|
||||
|
||||
// ToLowerMap makes all the keys in the given map lower cased and will do so
|
||||
// recursively.
|
||||
// Notes:
|
||||
// * This will modify the map given.
|
||||
// * Any nested map[interface{}]interface{} will be converted to map[string]interface{}.
|
||||
func ToLowerMap(m map[string]interface{}) {
|
||||
for k, v := range m {
|
||||
switch v.(type) {
|
||||
case map[interface{}]interface{}:
|
||||
v = cast.ToStringMap(v)
|
||||
ToLowerMap(v.(map[string]interface{}))
|
||||
case map[string]interface{}:
|
||||
ToLowerMap(v.(map[string]interface{}))
|
||||
}
|
||||
|
||||
lKey := strings.ToLower(k)
|
||||
if k != lKey {
|
||||
delete(m, k)
|
||||
}
|
||||
m[lKey] = v
|
||||
}
|
||||
}
|
||||
|
||||
// ReaderToString is the same as ReaderToBytes, but returns a string.
|
||||
func ReaderToString(lines io.Reader) string {
|
||||
if lines == nil {
|
||||
|
Reference in New Issue
Block a user