Commits

Ross Light committed 109e053

Allow match parameters to be a superset of MediaRange parameters

Comments (0)

Files changed (2)

 		match.Subtype++
 	}
 
-	if len(mr.Params) == 0 {
-		match.Valid = true
-		return match
-	} else if len(params) != len(mr.Params) {
-		return match
-	}
-	for k, v1 := range params {
-		v2, ok := mr.Params[k]
+	for k, v1 := range mr.Params {
+		v2, ok := params[k]
 		if !ok {
 			return match
 		}
 				return match
 			}
 		}
+		match.Params++
 	}
-	match.Params++
 	match.Valid = true
 	return match
 }
 		{
 			"text/html", map[string][]string{"level": {"1"}},
 			"text/html", map[string][]string{"level": {"1"}, "foo": {"bar"}},
-			mediaRangeMatch{nil, false, 1, 1, 0},
+			mediaRangeMatch{nil, true, 1, 1, 1},
 		},
 		{
-			"text/html", map[string][]string{"level": {"1"}, "foo": {"bar"}},
-			"text/html", map[string][]string{"level": {"1"}},
-			mediaRangeMatch{nil, false, 1, 1, 0},
+			"text/html", map[string][]string{"level": {"1"}, "charset": {"utf-8"}},
+			"text/html", map[string][]string{"level": {"1"}, "charset": {"utf-8"}, "foo": {"bar"}},
+			mediaRangeMatch{nil, true, 1, 1, 2},
 		},
 	}
 	for _, test := range tests {