@@ -1008,12 +1008,16 @@ impl Config {
1008
1008
/// Gets the index for a registry.
1009
1009
pub fn get_registry_index ( & self , registry : & str ) -> CargoResult < Url > {
1010
1010
validate_package_name ( registry, "registry name" , "" ) ?;
1011
- Ok (
1012
- match self . get_string ( & format ! ( "registries.{}.index" , registry) ) ? {
1013
- Some ( index) => self . resolve_registry_index ( index) ?,
1014
- None => bail ! ( "No index found for registry: `{}`" , registry) ,
1015
- } ,
1016
- )
1011
+ if let Some ( index) = self . get_string ( & format ! ( "registries.{}.index" , registry) ) ? {
1012
+ self . resolve_registry_index ( & index) . chain_err ( || {
1013
+ format ! (
1014
+ "invalid index URL for registry `{}` defined in {}" ,
1015
+ registry, index. definition
1016
+ )
1017
+ } )
1018
+ } else {
1019
+ bail ! ( "no index found for registry: `{}`" , registry) ;
1020
+ }
1017
1021
}
1018
1022
1019
1023
/// Returns an error if `registry.index` is set.
@@ -1027,7 +1031,8 @@ impl Config {
1027
1031
Ok ( ( ) )
1028
1032
}
1029
1033
1030
- fn resolve_registry_index ( & self , index : Value < String > ) -> CargoResult < Url > {
1034
+ fn resolve_registry_index ( & self , index : & Value < String > ) -> CargoResult < Url > {
1035
+ // This handles relative file: URLs, relative to the config definition.
1031
1036
let base = index
1032
1037
. definition
1033
1038
. root ( self )
@@ -1036,7 +1041,7 @@ impl Config {
1036
1041
let _parsed = index. val . into_url ( ) ?;
1037
1042
let url = index. val . into_url_with_base ( Some ( & * base) ) ?;
1038
1043
if url. password ( ) . is_some ( ) {
1039
- bail ! ( "Registry URLs may not contain passwords" ) ;
1044
+ bail ! ( "registry URLs may not contain passwords" ) ;
1040
1045
}
1041
1046
Ok ( url)
1042
1047
}
0 commit comments