@@ -10,7 +10,8 @@ use rustc_hash::{FxHashMap, FxHashSet};
1010use thiserror:: Error ;
1111use tracing:: trace;
1212use url:: { ParseError , Url } ;
13-
13+ use uv_auth:: RealmRef ;
14+ use uv_cache_key:: CanonicalUrl ;
1415use uv_pep508:: { Scheme , VerbatimUrl , VerbatimUrlError , split_scheme} ;
1516use uv_redacted:: DisplaySafeUrl ;
1617use uv_warnings:: warn_user;
@@ -292,6 +293,12 @@ impl IndexLocations {
292293 }
293294}
294295
296+ /// Returns `true` if two [`IndexUrl`]s refer to the same index.
297+ fn is_same_index ( a : & IndexUrl , b : & IndexUrl ) -> bool {
298+ RealmRef :: from ( & * * b. url ( ) ) == RealmRef :: from ( & * * a. url ( ) )
299+ && CanonicalUrl :: new ( a. url ( ) ) == CanonicalUrl :: new ( b. url ( ) )
300+ }
301+
295302impl < ' a > IndexLocations {
296303 /// Return the default [`Index`] entry.
297304 ///
@@ -456,7 +463,7 @@ impl<'a> IndexLocations {
456463 /// Return the Simple API cache control header for an [`IndexUrl`], if configured.
457464 pub fn simple_api_cache_control_for ( & self , url : & IndexUrl ) -> Option < & str > {
458465 for index in & self . indexes {
459- if index. url ( ) == url {
466+ if is_same_index ( index. url ( ) , url) {
460467 return index. simple_api_cache_control ( ) ;
461468 }
462469 }
@@ -466,7 +473,7 @@ impl<'a> IndexLocations {
466473 /// Return the artifact cache control header for an [`IndexUrl`], if configured.
467474 pub fn artifact_cache_control_for ( & self , url : & IndexUrl ) -> Option < & str > {
468475 for index in & self . indexes {
469- if index. url ( ) == url {
476+ if is_same_index ( index. url ( ) , url) {
470477 return index. artifact_cache_control ( ) ;
471478 }
472479 }
@@ -599,7 +606,7 @@ impl<'a> IndexUrls {
599606 /// Return the [`IndexStatusCodeStrategy`] for an [`IndexUrl`].
600607 pub fn status_code_strategy_for ( & self , url : & IndexUrl ) -> IndexStatusCodeStrategy {
601608 for index in & self . indexes {
602- if index. url ( ) == url {
609+ if is_same_index ( index. url ( ) , url) {
603610 return index. status_code_strategy ( ) ;
604611 }
605612 }
@@ -609,7 +616,7 @@ impl<'a> IndexUrls {
609616 /// Return the Simple API cache control header for an [`IndexUrl`], if configured.
610617 pub fn simple_api_cache_control_for ( & self , url : & IndexUrl ) -> Option < & str > {
611618 for index in & self . indexes {
612- if index. url ( ) == url {
619+ if is_same_index ( index. url ( ) , url) {
613620 return index. simple_api_cache_control ( ) ;
614621 }
615622 }
@@ -619,7 +626,7 @@ impl<'a> IndexUrls {
619626 /// Return the artifact cache control header for an [`IndexUrl`], if configured.
620627 pub fn artifact_cache_control_for ( & self , url : & IndexUrl ) -> Option < & str > {
621628 for index in & self . indexes {
622- if index. url ( ) == url {
629+ if is_same_index ( index. url ( ) , url) {
623630 return index. artifact_cache_control ( ) ;
624631 }
625632 }
0 commit comments