| 1 | //! REST versions use a header, leaving GitHub-compatible URLs unprefixed. |
| 2 | pub const HEADER: &str = "x-g1t-api-version"; |
| 3 | pub const CURRENT: &str = "1"; |
| 4 | |
| 5 | pub fn supported(value: Option<&str>) -> bool { |
| 6 | value.is_none_or(|value| value.trim() == CURRENT) |
| 7 | } |
| 8 | |
| 9 | #[cfg(test)] |
| 10 | mod tests { |
| 11 | use super::*; |
| 12 | #[test] |
| 13 | fn omitted_versions_keep_working_and_unknown_versions_are_not_silently_accepted() { |
| 14 | assert!(supported(None)); |
| 15 | assert!(supported(Some("1"))); |
| 16 | assert!(supported(Some(" 1 "))); |
| 17 | for value in ["", "2", "latest", "1, 2"] { assert!(!supported(Some(value))); } |
| 18 | } |
| 19 | } |