allow-report 0.1.5

Report and receipt rendering for cargo-allow source exception scans.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use allow_core::normalize_path;
use std::path::Path;

pub fn source_tree_path_text(path: &Path) -> String {
    let text = path.to_string_lossy().replace('\\', "/");
    if let Some(stripped) = text.strip_prefix("//?/UNC/") {
        return format!("//{stripped}");
    }
    if let Some(stripped) = text.strip_prefix("//?/") {
        return stripped.to_string();
    }
    if let Some(stripped) = text.strip_prefix("/?/") {
        return stripped.to_string();
    }
    normalize_path(path)
}