Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.9.0 #13

Merged
merged 2 commits into from
Mar 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ lazy_static! {
static ref RX_PPC_OS_VERSION: Regex = Regex::new(r"rv:(\d+\.\d+\.\d+)").unwrap();
static ref RX_FREEBSD_OS_VERSION: Regex = Regex::new(r"FreeBSD ([^;\)]+);").unwrap();
static ref RX_CHROMEOS_OS_VERSION: Regex = Regex::new(r"CrOS ([^\)]+)\)").unwrap();
static ref RX_ANDROIDOS_OS_VERSION: Regex = Regex::new(r"Android[- ](\d+\.\d+(?:\.\d+)?)").unwrap();
static ref RX_ANDROIDOS_OS_VERSION: Regex = Regex::new(r"Android[- ](\d+(?:\.\d+(?:\.\d+)?)?)").unwrap();
static ref RX_PSP_OS_VERSION: Regex = Regex::new(r"PSP \(PlayStation Portable\); ([.0-9]+)\)").unwrap();
static ref RX_PS3_OS_VERSION: Regex = Regex::new(r"PLAYSTATION 3;? ([.0-9]+)\)").unwrap();
static ref RX_PSVITA_OS_VERSION: Regex = Regex::new(r"PlayStation Vita ([.0-9]+)\)").unwrap();
10 changes: 10 additions & 0 deletions tests/smartphone_android.rs
Original file line number Diff line number Diff line change
@@ -108,5 +108,15 @@ mod tests {
assert_eq!(result.version, "4.0");
}
}
match parser.parse(r#"Mozilla/5.0 (Linux; Android 9; SM-N960F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.105 Mobile Safari/537.36"#) {
None => panic!(r#"invalid parse. "Mozilla/5.0 (Linux; Android 9; SM-N960F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.105 Mobile Safari/537.36""#),
Some(result) => {
assert_eq!(result.category, "smartphone");
assert_eq!(result.name, "Chrome");
assert_eq!(result.os, "Android");
assert_eq!(result.os_version, "9".to_string());
assert_eq!(result.version, "72.0.3626.105");
}
}
}
}