Skip to main content

rmv_core/
agent.rs

1//! The User-Agent, which names the project so RMV can tell where requests
2//! come from.
3
4/// The project, named in every User-Agent.
5pub const PROJECT_URL: &str = "https://github.com/udondan/rmv";
6
7/// The User-Agent for `product`, like `rmv/1.2.0`.
8pub fn user_agent(product: &str) -> String {
9    format!("{product} (+{PROJECT_URL})")
10}
11
12#[cfg(test)]
13mod tests {
14    use super::*;
15
16    #[test]
17    fn names_product_and_project() {
18        assert_eq!(
19            user_agent("rmv/1.0.0"),
20            "rmv/1.0.0 (+https://github.com/udondan/rmv)"
21        );
22    }
23}