Skip to content

Commit

Permalink
Release 0.5.1
Browse files Browse the repository at this point in the history
- Exit early in device and OS matchers (#11) <@jan-auer>
  • Loading branch information
David Armstrong Lewis committed Feb 18, 2022
1 parent f0f53d2 commit 3fc6592
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "uaparser"
version = "0.5.0"
version = "0.5.1"
description = "A Rust implementation of the UA Parser"
license = "MIT"
authors = ["David Lewis <[email protected]>"]
Expand Down
18 changes: 9 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions nix/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ mkShell {
extensions = [ "rust-src" ];
})
cargo-criterion
gnuplot
];
}
4 changes: 4 additions & 0 deletions src/parser/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ impl SubParser for Matcher {
type Item = Device;

fn try_parse(&self, text: &str) -> Option<Self::Item> {
if !self.regex.is_match(text) {
return None;
}

if let Some(captures) = self.regex.captures(text) {
let family: String =
if let Some(device_replacement) = &self.device_replacement {
Expand Down
4 changes: 4 additions & 0 deletions src/parser/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ impl SubParser for Matcher {
type Item = OS;

fn try_parse(&self, text: &str) -> Option<Self::Item> {
if !self.regex.is_match(text) {
return None;
}

if let Some(captures) = self.regex.captures(text) {
let family: String = if let Some(os_replacement) = &self.os_replacement {
replace(os_replacement, &captures)
Expand Down

0 comments on commit 3fc6592

Please sign in to comment.