mirror of
https://github.com/xvxx/phetch
synced 2024-11-05 00:00:58 +00:00
fix bug in text urls
This commit is contained in:
parent
301f022c22
commit
caedc35c90
@ -234,6 +234,7 @@ pub fn type_for_url(url: &str) -> Type {
|
||||
return Type::HTML;
|
||||
}
|
||||
|
||||
let url = url.trim_start_matches("gopher://");
|
||||
if let Some(idx) = url.find('/') {
|
||||
if let Some(t) = url.chars().nth(idx + 1) {
|
||||
return Type::from(t).unwrap_or(Type::Menu);
|
||||
@ -430,6 +431,10 @@ mod tests {
|
||||
assert_eq!(type_for_url("phkt.io/1"), Type::Menu);
|
||||
assert_eq!(type_for_url("phkt.io/1/"), Type::Menu);
|
||||
assert_eq!(type_for_url("phkt.io/0/info.txt"), Type::Text);
|
||||
assert_eq!(
|
||||
type_for_url("gopher://vernunftzentrum.de/0/tfurrows/resources/tokipona.txt"),
|
||||
Type::Text
|
||||
);
|
||||
assert_eq!(type_for_url("URL:https://google.com"), Type::HTML);
|
||||
assert_eq!(
|
||||
type_for_url("telnet://bbs.inter.net:6502/connect"),
|
||||
|
Loading…
Reference in New Issue
Block a user