Remove unneeded casts in page.getParam
authorSam Broughton <sambroughton@hotmail.co.uk>
Mon, 6 Jun 2016 22:20:22 +0000 (23:20 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 9 Jun 2016 13:40:06 +0000 (15:40 +0200)
Closes #2186

hugolib/page.go

index cff84737b7ec5f5c61680dd7076472ce2c8ca941..68f62e8f44f9514df09a0ad309282918dffbc2a5 100644 (file)
@@ -671,26 +671,26 @@ func (p *Page) getParam(key string, stringToLower bool) interface{} {
 
        switch v.(type) {
        case bool:
-               return cast.ToBool(v)
-       case string:
-               if stringToLower {
-                       return strings.ToLower(cast.ToString(v))
-               }
-               return cast.ToString(v)
+               return v
+       case time.Time:
+               return v
        case int64, int32, int16, int8, int:
                return cast.ToInt(v)
        case float64, float32:
                return cast.ToFloat64(v)
-       case time.Time:
-               return cast.ToTime(v)
+       case map[string]interface{}: // JSON and TOML
+               return v
+       case map[interface{}]interface{}: // YAML
+               return v
+       case string:
+               if stringToLower {
+                       return strings.ToLower(v.(string))
+               }
+               return v
        case []string:
                if stringToLower {
                        return helpers.SliceToLower(v.([]string))
                }
-               return v.([]string)
-       case map[string]interface{}: // JSON and TOML
-               return v
-       case map[interface{}]interface{}: // YAML
                return v
        }