recognize more gopher types, fix validation and a minor error

master
Lukáš Hozda 4 years ago
parent 53c88d4fb7
commit f37258f294

@ -68,7 +68,7 @@ impl BrowserState {
parsed_selector: String::new(),
bookmarks: Vec::new(),
config: Config {
start_uri: String::from("gopher://r-36.net:70"),
start_uri: String::from("gopher://gopher.floodgap.com:70"),
cmd_text: String::from("less"),
cmd_image: String::from("display"),
cmd_browser: String::from("firefox"),
@ -306,14 +306,14 @@ impl BrowserState {
}
for line in buffer.lines() {
// if !is_valid_directory_entry(line.chars().next().unwrap_or('\0')) {
// println!(
// "error: not a directory: [{}] {}",
// line.chars().next().unwrap_or('\0'),
// line.chars().skip(1).collect::<String>()
// );
// return;
// }
if !is_valid_directory_entry(line.chars().next().unwrap_or('\0')) {
println!(
"invalid: [{}] {}",
line.chars().next().unwrap_or('\0'),
line.chars().skip(1).collect::<String>()
);
continue;
}
self.handle_directory_line(line);
}
@ -719,7 +719,7 @@ impl BrowserState {
line.chars().skip(2).next().unwrap_or('\0'),
));
},
_ => {
x if !x.is_none() => {
self.follow_link(
make_key(
line.chars().next().unwrap(),
@ -728,6 +728,7 @@ impl BrowserState {
.unwrap_or(0),
);
}
_ => (),
}
}
/* never get's here but stops cc complaining */
@ -818,7 +819,7 @@ pub fn make_key_str(
pub fn is_valid_directory_entry(kind: char) -> bool {
match kind {
'i' | '3' | '.' | '0' | '1' | '5' | '7' | '8' | '9' | 'g' | 'I' | 'p' | 'h'
'i' | '3' | '.' | '0' | '1' | '5' | '7' | '8' | '9' | 'g' | 'I' | 'p' | 'h' | '2' | 'd'
| 's' => true,
_ => false,
}

Loading…
Cancel
Save