@@ -122,6 +122,9 @@ pub async fn publish(app: AppState, req: BytesRequest) -> AppResult<Json<GoodCra
122122 let description = package. description . map ( |it| it. as_local ( ) . unwrap ( ) ) ;
123123 let mut license = package. license . map ( |it| it. as_local ( ) . unwrap ( ) ) ;
124124 let license_file = package. license_file . map ( |it| it. as_local ( ) . unwrap ( ) ) ;
125+ let homepage = package. homepage . map ( |it| it. as_local ( ) . unwrap ( ) ) ;
126+ let documentation = package. documentation . map ( |it| it. as_local ( ) . unwrap ( ) ) ;
127+ let repository = package. repository . map ( |it| it. as_local ( ) . unwrap ( ) ) ;
125128
126129 // Make sure required fields are provided
127130 fn empty ( s : Option < & String > ) -> bool {
@@ -150,13 +153,16 @@ pub async fn publish(app: AppState, req: BytesRequest) -> AppResult<Json<GoodCra
150153 license = Some ( String :: from ( "non-standard" ) ) ;
151154 }
152155
156+ validate_url ( homepage. as_deref ( ) , "homepage" ) ?;
157+ validate_url ( documentation. as_deref ( ) , "documentation" ) ?;
158+ validate_url ( repository. as_deref ( ) , "repository" ) ?;
159+
153160 // Create a transaction on the database, if there are no errors,
154161 // commit the transactions to record a new or updated crate.
155162 conn. transaction ( |conn| {
156163 let name = metadata. name ;
157164 let vers = & * metadata. vers ;
158165 let links = metadata. links ;
159- let repo = metadata. repository ;
160166 let features = metadata
161167 . features
162168 . into_iter ( )
@@ -177,17 +183,13 @@ pub async fn publish(app: AppState, req: BytesRequest) -> AppResult<Json<GoodCra
177183 let persist = NewCrate {
178184 name : & name,
179185 description : description. as_deref ( ) ,
180- homepage : metadata . homepage . as_deref ( ) ,
181- documentation : metadata . documentation . as_deref ( ) ,
186+ homepage : homepage. as_deref ( ) ,
187+ documentation : documentation. as_deref ( ) ,
182188 readme : metadata. readme . as_deref ( ) ,
183- repository : repo . as_deref ( ) ,
189+ repository : repository . as_deref ( ) ,
184190 max_upload_size : None ,
185191 } ;
186192
187- validate_url ( persist. homepage , "homepage" ) ?;
188- validate_url ( persist. documentation , "documentation" ) ?;
189- validate_url ( persist. repository , "repository" ) ?;
190-
191193 if is_reserved_name ( persist. name , conn) ? {
192194 return Err ( cargo_err ( "cannot upload a crate with a reserved name" ) ) ;
193195 }
@@ -271,7 +273,7 @@ pub async fn publish(app: AppState, req: BytesRequest) -> AppResult<Json<GoodCra
271273 metadata
272274 . readme_file
273275 . unwrap_or_else ( || String :: from ( "README.md" ) ) ,
274- repo ,
276+ repository ,
275277 pkg_path_in_vcs,
276278 )
277279 . enqueue_with_priority ( conn, PRIORITY_RENDER_README ) ?;
0 commit comments