@@ -462,7 +462,7 @@ func checkForRouteOverlap(route *L7Route, hostPortPaths map[string]string) *cond
462462 port := parentRef .Attachment .ListenerPort
463463 for _ , hostnames := range parentRef .Attachment .AcceptedHostnames {
464464 mergedHostnames := getMergedHostnames (route , hostnames )
465- if cond := checkHostnamesOverlap (route , mergedHostnames , port , hostPortPaths ); cond != nil {
465+ if cond := checkURIsOverlap (route , mergedHostnames , port , hostPortPaths ); cond != nil {
466466 return cond
467467 }
468468 }
@@ -483,47 +483,36 @@ func getMergedHostnames(route *L7Route, hostnames []string) []string {
483483}
484484
485485func getHostnameMatches (hostname string , routeHostnames []v1.Hostname ) []string {
486- foundExactMatch := false
487486 moreSpecificHostnames := make ([]string , 0 )
488487
489488 for _ , h := range routeHostnames {
490489 if hostname == string (h ) {
491- foundExactMatch = true
492- break
490+ return []string {hostname }
493491 }
494- if Match (hostname , string (h )) {
492+ if match (hostname , string (h )) {
495493 moreSpecificHostnames = append (moreSpecificHostnames , GetMoreSpecificHostname (hostname , string (h )))
496494 }
497495 }
498496
499- if foundExactMatch {
500- return []string {hostname }
501- }
502497 return moreSpecificHostnames
503498}
504499
505- func checkHostnamesOverlap (
506- route * L7Route , hostnames []string , port v1.PortNumber , hostPortPaths map [string ]string ,
500+ func checkURIsOverlap (
501+ route * L7Route ,
502+ hostnames []string ,
503+ port v1.PortNumber ,
504+ hostPortPaths map [string ]string ,
507505) * conditions.Condition {
508506 for _ , hostname := range hostnames {
509- if cond := checkHostnamePathsOverlap (route , hostname , port , hostPortPaths ); cond != nil {
510- return cond
511- }
512- }
513- return nil
514- }
515-
516- func checkHostnamePathsOverlap (
517- route * L7Route , hostname string , port v1.PortNumber , hostPortPaths map [string ]string ,
518- ) * conditions.Condition {
519- for _ , rule := range route .Spec .Rules {
520- for _ , match := range rule .Matches {
521- if match .Path != nil && match .Path .Value != nil {
522- key := fmt .Sprintf ("%s:%d%s" , hostname , port , * match .Path .Value )
523- if val , ok := hostPortPaths [key ]; ! ok {
524- hostPortPaths [key ] = fmt .Sprintf ("%s/%s" , route .Source .GetNamespace (), route .Source .GetName ())
525- } else {
526- return createTargetConflictCondition (route , val )
507+ for _ , rule := range route .Spec .Rules {
508+ for _ , match := range rule .Matches {
509+ if match .Path != nil && match .Path .Value != nil {
510+ key := fmt .Sprintf ("%s:%d%s" , hostname , port , * match .Path .Value )
511+ if val , ok := hostPortPaths [key ]; ! ok {
512+ hostPortPaths [key ] = fmt .Sprintf ("%s/%s" , route .Source .GetNamespace (), route .Source .GetName ())
513+ } else {
514+ return createTargetConflictCondition (route , val )
515+ }
527516 }
528517 }
529518 }
0 commit comments