@@ -14,6 +14,7 @@ use sha2::{Sha256, Sha512};
1414use std:: { sync:: Arc , time:: SystemTime } ;
1515use time:: { OffsetDateTime , format_description:: well_known:: Rfc2822 } ;
1616use url:: { ParseError , Url } ;
17+ use walker_common:: utils:: url:: ensure_slash;
1718use walker_common:: {
1819 changes:: { self , ChangeEntry , ChangeSource } ,
1920 fetcher:: { self , DataProcessor , Fetcher } ,
@@ -117,23 +118,15 @@ impl Source for HttpSource {
117118
118119 match discover_context. as_ref ( ) {
119120 DistributionContext :: Directory ( base) => {
120- let has_slash = base. to_string ( ) . ends_with ( '/' ) ;
121-
122- let join_url = |mut s : & str | {
123- if has_slash && s. ends_with ( '/' ) {
124- s = & s[ 1 ..] ;
125- }
126- Url :: parse ( & format ! ( "{base}{s}" ) )
127- } ;
128-
129- let changes = ChangeSource :: retrieve ( & self . fetcher , & base. clone ( ) ) . await ?;
121+ let base = ensure_slash ( base. clone ( ) ) ;
122+ let changes = ChangeSource :: retrieve ( & self . fetcher , & base) . await ?;
130123
131124 Ok ( changes
132125 . entries
133126 . into_iter ( )
134127 . map ( |ChangeEntry { file, timestamp } | {
135128 let modified = timestamp. into ( ) ;
136- let url = join_url ( & file) ?;
129+ let url = base . join ( & file) ?;
137130
138131 Ok :: < _ , ParseError > ( DiscoveredAdvisory {
139132 context : discover_context. clone ( ) ,
0 commit comments