File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -43,18 +43,22 @@ pub fn build_list_handler(req: &mut Request) -> IronResult<Response> {
43
43
let mut conn = extension ! ( req, Pool ) . get ( ) ?;
44
44
let limits = ctry ! ( req, Limits :: for_crate( & mut conn, name) ) ;
45
45
46
+ let is_json = req. url . path ( ) . join ( "/" ) . ends_with ( ".json" ) ;
47
+
46
48
let version =
47
49
match match_version ( & mut conn, name, req_version) . and_then ( |m| m. assume_exact ( ) ) ? {
48
50
MatchSemver :: Exact ( ( version, _) ) => version,
49
51
50
52
MatchSemver :: Semver ( ( version, _) ) => {
53
+ let ext = if is_json { ".json" } else { "" } ;
51
54
let url = ctry ! (
52
55
req,
53
56
Url :: parse( & format!(
54
- "{}/crate/{}/{}/builds" ,
57
+ "{}/crate/{}/{}/builds{} " ,
55
58
redirect_base( req) ,
56
59
name,
57
- version
60
+ version,
61
+ ext
58
62
) ) ,
59
63
) ;
60
64
@@ -95,7 +99,7 @@ pub fn build_list_handler(req: &mut Request) -> IronResult<Response> {
95
99
} )
96
100
. collect ( ) ;
97
101
98
- if req . url . path ( ) . join ( "/" ) . ends_with ( ".json" ) {
102
+ if is_json {
99
103
let mut resp = Response :: with ( ( status:: Ok , serde_json:: to_string ( & builds) . unwrap ( ) ) ) ;
100
104
resp. headers . set ( ContentType :: json ( ) ) ;
101
105
resp. headers . set ( Expires ( HttpDate ( time:: now ( ) ) ) ) ;
You can’t perform that action at this time.
0 commit comments