File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 1
1
use chrono:: NaiveDateTime ;
2
+ use std:: iter:: { IntoIterator , Iterator } ;
2
3
use url:: Url ;
3
4
4
5
use crate :: github;
@@ -361,11 +362,16 @@ impl EncodableCrate {
361
362
fn domain_is_blocked ( domain : & str ) -> bool {
362
363
DOCUMENTATION_BLOCKLIST
363
364
. iter ( )
364
- . any ( |blocked| domain_is_subdomain ( domain, blocked) )
365
+ . any ( |blocked| & domain == blocked || domain_is_subdomain ( domain, blocked) )
365
366
}
366
367
367
368
fn domain_is_subdomain ( potential_subdomain : & str , root : & str ) -> bool {
368
- potential_subdomain. ends_with ( root)
369
+ if !potential_subdomain. ends_with ( root) {
370
+ return false ;
371
+ }
372
+
373
+ let root_with_prefix = format ! ( ".{root}" ) ;
374
+ potential_subdomain. ends_with ( & root_with_prefix)
369
375
}
370
376
371
377
#[ derive( Serialize , Deserialize , Debug ) ]
@@ -917,4 +923,11 @@ mod tests {
917
923
None
918
924
) ;
919
925
}
926
+
927
+ #[ test]
928
+ fn documentation_blocked_non_subdomain ( ) {
929
+ let input = Some ( String :: from ( "http://foorust-ci.org/" ) ) ;
930
+ let result = EncodableCrate :: remove_blocked_documentation_urls ( input) ;
931
+ assert_some_eq ! ( result, "http://foorust-ci.org/" ) ;
932
+ }
920
933
}
You can’t perform that action at this time.
0 commit comments