This repository was archived by the owner on Nov 20, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -650,6 +650,7 @@ private bool MatchesSubtype(MediaTypeHeaderValue set)
650650 {
651651 return true ;
652652 }
653+
653654 if ( set . Suffix . HasValue )
654655 {
655656 if ( Suffix . HasValue )
@@ -663,7 +664,10 @@ private bool MatchesSubtype(MediaTypeHeaderValue set)
663664 }
664665 else
665666 {
666- return set . SubType . Equals ( SubType , StringComparison . OrdinalIgnoreCase ) ;
667+ // If this subtype or suffix matches the subtype of the set,
668+ // it is considered a subtype.
669+ // Ex: application/json > application/val+json
670+ return MatchesEitherSubtypeOrSuffix ( set ) ;
667671 }
668672 }
669673
@@ -673,6 +677,12 @@ private bool MatchesSubtypeWithoutSuffix(MediaTypeHeaderValue set)
673677 set . SubTypeWithoutSuffix . Equals ( SubTypeWithoutSuffix , StringComparison . OrdinalIgnoreCase ) ;
674678 }
675679
680+ private bool MatchesEitherSubtypeOrSuffix ( MediaTypeHeaderValue set )
681+ {
682+ return set . SubType . Equals ( SubType , StringComparison . OrdinalIgnoreCase ) ||
683+ set . SubType . Equals ( Suffix , StringComparison . OrdinalIgnoreCase ) ;
684+ }
685+
676686 private bool MatchesParameters ( MediaTypeHeaderValue set )
677687 {
678688 if ( set . _parameters != null && set . _parameters . Count != 0 )
Original file line number Diff line number Diff line change @@ -750,6 +750,8 @@ public void IsSubsetOf_NegativeCases(string mediaType1, string mediaType2)
750750 [ InlineData ( "application/entity+json" , "application/entity+json" ) ]
751751 [ InlineData ( "application/*+json" , "application/entity+json" ) ]
752752 [ InlineData ( "application/*+json" , "application/*+json" ) ]
753+ [ InlineData ( "application/json" , "application/problem+json" ) ]
754+ [ InlineData ( "application/json" , "application/vnd.restful+json" ) ]
753755 [ InlineData ( "application/*" , "application/*+JSON" ) ]
754756 [ InlineData ( "application/vnd.github+json" , "application/vnd.github+json" ) ]
755757 [ InlineData ( "application/*" , "application/entity+JSON" ) ]
@@ -774,6 +776,7 @@ public void IsSubsetOfWithSuffixes_PositiveCases(string set, string subset)
774776 [ InlineData ( "application/*+*" , "application/json" ) ]
775777 [ InlineData ( "application/entity+*" , "application/entity+json" ) ] // We don't allow suffixes to be wildcards
776778 [ InlineData ( "application/*+*" , "application/entity+json" ) ] // We don't allow suffixes to be wildcards
779+ [ InlineData ( "application/entity+json" , "application/entity" ) ]
777780 public void IsSubSetOfWithSuffixes_NegativeCases ( string set , string subset )
778781 {
779782 // Arrange
You can’t perform that action at this time.
0 commit comments