Minimal RFC 4648 base64 encoder (no external dependency).
(input: &[u8])
| 360 | } |
| 361 | } |
| 362 | _ => current.push('\\'), |
| 363 | } |
| 364 | } |
| 365 | } |
| 366 | _ => current.push(c), |
| 367 | }, |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | if !matches!(quote, Quote::None) { |
| 372 | return Err("Unterminated quote in curl command".into()); |
| 373 | } |
| 374 | if in_token { |
| 375 | tokens.push(current); |
| 376 | } |
| 377 | |
| 378 | Ok(tokens) |
| 379 | } |
| 380 | |
| 381 | #[cfg(test)] |
| 382 | mod tests { |
| 383 | use super::*; |
| 384 | |
| 385 | #[test] |
| 386 | fn detects_curl_prefix() { |
| 387 | assert!(looks_like_curl("curl https://example.com")); |
| 388 | assert!(looks_like_curl(" curl https://example.com")); |
| 389 | assert!(!looks_like_curl("https://example.com")); |
| 390 | assert!(!looks_like_curl("curlhttps://example.com")); |
| 391 | } |
| 392 |