@@ -68,11 +68,8 @@ fn ident(location: &Location) -> String {
68
68
str:: from_utf8 ( last) . unwrap ( ) . to_str ( )
69
69
}
70
70
Remote ( ref url) => {
71
- // Remove the trailing '/' so that 'split' doesn't give us
72
- // an empty string, making '../foo/' and '../foo' both
73
- // result in the name 'foo' (#84)
74
71
let path = strip_trailing_slash ( url. path . as_slice ( ) ) ;
75
- path. split ( '/' ) . last ( ) . unwrap ( ) . to_str ( )
72
+ path. as_slice ( ) . split ( '/' ) . last ( ) . unwrap ( ) . to_str ( )
76
73
}
77
74
} ;
78
75
@@ -82,17 +79,36 @@ fn ident(location: &Location) -> String {
82
79
ident
83
80
} ;
84
81
85
- format ! ( "{}-{}" , ident, to_hex( hasher. hash( & location. to_str( ) ) ) )
82
+ let location = canonicalize_url ( location. to_str ( ) . as_slice ( ) ) ;
83
+
84
+ format ! ( "{}-{}" , ident, to_hex( hasher. hash( & location. as_slice( ) ) ) )
86
85
}
87
86
88
87
fn strip_trailing_slash < ' a > ( path : & ' a str ) -> & ' a str {
88
+ // Remove the trailing '/' so that 'split' doesn't give us
89
+ // an empty string, making '../foo/' and '../foo' both
90
+ // result in the name 'foo' (#84)
89
91
if path. as_bytes ( ) . last ( ) != Some ( & ( '/' as u8 ) ) {
90
92
path. clone ( )
91
93
} else {
92
94
path. slice ( 0 , path. len ( ) - 1 )
93
95
}
94
96
}
95
97
98
+ fn canonicalize_url ( url : & str ) -> String {
99
+ // HACKHACK: For github URL's specifically just lowercase
100
+ // everything. GitHub traits both the same, but they hash
101
+ // differently, and we're gonna be hashing them. This wants a more
102
+ // general solution, and also we're almost certainly not using the
103
+ // same case conversion rules that GitHub does. (#84)
104
+ let lower_url = url. chars ( ) . map ( |c|c. to_lowercase ( ) ) . collect :: < String > ( ) ;
105
+ if lower_url. as_slice ( ) . contains ( "github.com" ) {
106
+ lower_url
107
+ } else {
108
+ url. to_string ( )
109
+ }
110
+ }
111
+
96
112
impl < ' a , ' b > Show for GitSource < ' a , ' b > {
97
113
fn fmt ( & self , f : & mut Formatter ) -> fmt:: Result {
98
114
try!( write ! ( f, "git repo at {}" , self . remote. get_location( ) ) ) ;
0 commit comments