@@ -11,6 +11,7 @@ namespace Asp.Versioning.Routing;
11
11
internal sealed class ApiVersionPolicyJumpTable : PolicyJumpTable
12
12
{
13
13
private readonly bool versionsByUrl ;
14
+ private readonly bool versionsByUrlOnly ;
14
15
private readonly bool versionsByMediaTypeOnly ;
15
16
private readonly RouteDestination rejection ;
16
17
private readonly IReadOnlyDictionary < ApiVersion , int > destinations ;
@@ -32,6 +33,7 @@ internal ApiVersionPolicyJumpTable(
32
33
this . parser = parser ;
33
34
this . options = options ;
34
35
versionsByUrl = routePatterns . Count > 0 ;
36
+ versionsByUrlOnly = source . VersionsByUrl ( allowMultipleLocations : false ) ;
35
37
versionsByMediaTypeOnly = source . VersionsByMediaType ( allowMultipleLocations : false ) ;
36
38
}
37
39
@@ -61,15 +63,18 @@ public override int GetDestination( HttpContext httpContext )
61
63
return destination ;
62
64
}
63
65
64
- // 2. short-circuit if a default version cannot be assumed
65
- if ( ! options . AssumeDefaultVersionWhenUnspecified )
66
+ // 2. IApiVersionSelector cannot be used yet because there are no candidates that an
67
+ // aggregated version model can be computed from to select the 'default' API version
68
+ if ( options . AssumeDefaultVersionWhenUnspecified )
66
69
{
67
- return rejection . Unspecified ; // 400
70
+ return rejection . AssumeDefault ;
68
71
}
69
72
70
- // 3. IApiVersionSelector cannot be used yet because there are no candidates that an
71
- // aggregated version model can be computed from to select the 'default' API version
72
- return rejection . AssumeDefault ;
73
+ // 3. unspecified
74
+ return versionsByUrlOnly
75
+ /* 404 */ ? rejection . Exit
76
+ /* 400 */ : rejection . Unspecified ;
77
+
73
78
case 1 :
74
79
rawApiVersion = apiVersions [ 0 ] ;
75
80
0 commit comments