File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -221,7 +221,7 @@ impl<'a> RobotFileParser<'a> {
221221 disallow_all : Cell :: new ( false ) ,
222222 allow_all : Cell :: new ( false ) ,
223223 url : parsed_url. clone ( ) ,
224- host : parsed_url. domain ( ) . unwrap ( ) . to_owned ( ) ,
224+ host : parsed_url. host_str ( ) . unwrap ( ) . to_owned ( ) ,
225225 path : parsed_url. path ( ) . to_owned ( ) ,
226226 last_checked : Cell :: new ( 0i64 ) ,
227227 }
@@ -246,7 +246,7 @@ impl<'a> RobotFileParser<'a> {
246246 pub fn set_url < T : AsRef < str > > ( & mut self , url : T ) {
247247 let parsed_url = Url :: parse ( url. as_ref ( ) ) . unwrap ( ) ;
248248 self . url = parsed_url. clone ( ) ;
249- self . host = parsed_url. domain ( ) . unwrap ( ) . to_owned ( ) ;
249+ self . host = parsed_url. host_str ( ) . unwrap ( ) . to_owned ( ) ;
250250 self . path = parsed_url. path ( ) . to_owned ( ) ;
251251 self . last_checked . set ( 0i64 ) ;
252252 }
Original file line number Diff line number Diff line change @@ -268,3 +268,9 @@ fn test_robots_text_request_rate() {
268268 let req_rate = parser. get_req_rate ( "Google" ) ;
269269 assert ! ( req_rate. is_none( ) ) ;
270270}
271+
272+ #[ test]
273+ fn test_robots_127_0_0_1 ( ) {
274+ // Ensure it does not panic
275+ RobotFileParser :: new ( "http://127.0.0.1:4000/robots.txt" ) ;
276+ }
You can’t perform that action at this time.
0 commit comments