@@ -161,6 +161,25 @@ pub(crate) async fn index_packages(module: &IndexModule, config: &Config) -> any
161161 Ok ( ( ) )
162162}
163163
164+ fn one_or_many_to_url ( something : Option < OneOrMany < String > > ) -> Vec < Url > {
165+ match something {
166+ None => vec ! [ ] ,
167+ Some ( OneOrMany :: One ( homepage) ) => Url :: parse ( & homepage)
168+ . with_context ( || format ! ( "Failed to parse URL '{homepage}'" ) )
169+ . ok ( )
170+ . into_iter ( )
171+ . collect ( ) ,
172+ Some ( OneOrMany :: Many ( homepages) ) => homepages
173+ . into_iter ( )
174+ . filter_map ( |homepage| {
175+ Url :: parse ( & homepage)
176+ . with_context ( || format ! ( "Failed to parse URL '{homepage}'" ) )
177+ . ok ( )
178+ } )
179+ . collect ( ) ,
180+ }
181+ }
182+
164183fn into_package ( url_prefix : & Url , package : package:: Package ) -> anyhow:: Result < libixx:: Package > {
165184 static CVE_REGEX : LazyLock < Regex > = LazyLock :: new ( || Regex :: new ( r"CVE-(\d{4})-(\d+)" ) . unwrap ( ) ) ;
166185 static GHSA_REGEX : LazyLock < Regex > =
@@ -169,7 +188,7 @@ fn into_package(url_prefix: &Url, package: package::Package) -> anyhow::Result<l
169188 Ok ( libixx:: Package {
170189 attr_name : package. attr_name ,
171190 broken : package. broken ,
172- changelog : package. changelog ,
191+ changelogs : one_or_many_to_url ( package. changelog ) ,
173192 cpe : package. cpe ,
174193 declaration : package
175194 . declaration
@@ -181,22 +200,7 @@ fn into_package(url_prefix: &Url, package: package::Package) -> anyhow::Result<l
181200 disabled : package. disabled ,
182201 download_page : package. download_page ,
183202 eval_error : package. eval_error ,
184- homepages : match package. homepage {
185- None => vec ! [ ] ,
186- Some ( OneOrMany :: One ( homepage) ) => Url :: parse ( & homepage)
187- . with_context ( || format ! ( "Failed to parse URL '{homepage}'" ) )
188- . ok ( )
189- . into_iter ( )
190- . collect ( ) ,
191- Some ( OneOrMany :: Many ( homepages) ) => homepages
192- . into_iter ( )
193- . filter_map ( |homepage| {
194- Url :: parse ( & homepage)
195- . with_context ( || format ! ( "Failed to parse URL '{homepage}'" ) )
196- . ok ( )
197- } )
198- . collect ( ) ,
199- } ,
203+ homepages : one_or_many_to_url ( package. homepage ) ,
200204 known_vulnerabilities : package
201205 . known_vulnerabilities
202206 . unwrap_or_default ( )
0 commit comments