diff options
Diffstat (limited to 'atuin-server/src/utils.rs')
-rw-r--r-- | atuin-server/src/utils.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/atuin-server/src/utils.rs b/atuin-server/src/utils.rs new file mode 100644 index 000000000..12e9ac1bb --- /dev/null +++ b/atuin-server/src/utils.rs @@ -0,0 +1,15 @@ +use eyre::Result; +use semver::{Version, VersionReq}; + +pub fn client_version_min(user_agent: &str, req: &str) -> Result<bool> { + if user_agent.is_empty() { + return Ok(false); + } + + let version = user_agent.replace("atuin/", ""); + + let req = VersionReq::parse(req)?; + let version = Version::parse(version.as_str())?; + + Ok(req.matches(&version)) +} |