1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use cache_buster::Files;

fn main() {
    let files = Files::load();

    assert!(get_full_path_runner("../dist/log-out.svg", &files));
    assert!(get_full_path_runner(
        "../dist/a/b/c/d/s/d/svg/credit-card.svg",
        &files
    ));

    assert!(!get_full_path_runner("dist/log-out.svg", &files));
    assert!(!get_full_path_runner(
        "dist/a/b/c/d/s/d/svg/credit-card.svg",
        &files
    ));
}

fn get_full_path_runner(path: &str, files: &Files) -> bool {
    use std::path::Path;

    if let Some(file) = files.get_full_path(path) {
        Path::new(file).exists()
    } else {
        false
    }
}