mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Improve parse_hostsfile.
This commit is contained in:
parent
5946f756d7
commit
9f659e157a
1 changed files with 4 additions and 4 deletions
|
@ -37,10 +37,10 @@ fn create_host_table() -> Option<HashMap<String, IpAddr>> {
|
|||
pub fn parse_hostsfile(hostsfile_content: &str) -> HashMap<String, IpAddr> {
|
||||
let mut host_table = HashMap::new();
|
||||
for line in hostsfile_content.split('\n') {
|
||||
let ip_host: Vec<&str> = line.trim().split(|c: char| c == ' ' || c == '\t').collect();
|
||||
if ip_host.len() > 1 {
|
||||
if let Ok(address) = ip_host[0].parse::<IpAddr>() {
|
||||
for token in ip_host.iter().skip(1) {
|
||||
let mut ip_host = line.trim().split(|c: char| c == ' ' || c == '\t');
|
||||
if let Some(ip) = ip_host.next() {
|
||||
if let Ok(address) = ip.parse::<IpAddr>() {
|
||||
for token in ip_host {
|
||||
if token.as_bytes()[0] == b'#' {
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue