File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ use std::path::Path;
1717
1818/// Location of the crates.io index
1919pub const CRATES_IO_INDEX : & str = "https://github.com/rust-lang/crates.io-index" ;
20+ /// Location of the crates.io sparse HTTP index
21+ pub const CRATES_IO_SPARSE_INDEX : & str = "sparse+https://index.crates.io/" ;
2022
2123/// Default branch name
2224pub const DEFAULT_BRANCH : & str = "master" ;
@@ -236,8 +238,9 @@ impl SourceId {
236238
237239 /// Returns `true` if the remote registry is the standard <https://crates.io>.
238240 pub fn is_default_registry ( & self ) -> bool {
239- matches ! ( self . kind, SourceKind :: Registry | SourceKind :: SparseRegistry )
240- && self . url . as_str ( ) == CRATES_IO_INDEX
241+ self . kind == SourceKind :: Registry && self . url . as_str ( ) == CRATES_IO_INDEX
242+ || self . kind == SourceKind :: SparseRegistry
243+ && self . url . as_str ( ) == & CRATES_IO_SPARSE_INDEX [ 7 ..]
241244 }
242245}
243246
@@ -384,7 +387,10 @@ mod tests {
384387 use super :: SourceId ;
385388
386389 #[ test]
387- fn default_works ( ) {
388- SourceId :: default ( ) ;
390+ fn identifies_crates_io ( ) {
391+ assert ! ( SourceId :: default ( ) . is_default_registry( ) ) ;
392+ assert ! ( SourceId :: from_url( super :: CRATES_IO_SPARSE_INDEX )
393+ . expect( "failed to parse sparse URL" )
394+ . is_default_registry( ) ) ;
389395 }
390396}
You can’t perform that action at this time.
0 commit comments