mcaptcha/static_assets/
filemap.rs1use libcachebust::Files;
7
8pub struct FileMap {
9 pub files: Files,
10}
11
12impl FileMap {
13 #[allow(clippy::new_without_default)]
14 pub fn new() -> Self {
15 let map = include_str!("../libcachebust_data.json");
16 let files = Files::new(map);
17 Self { files }
18 }
19 pub fn get<'a>(&'a self, path: &'a str) -> Option<&'a str> {
20 let file_path = self.files.get_full_path(path);
21 file_path.map(|file_path| &file_path[1..])
22 }
23}
24
25#[cfg(test)]
26mod tests {
27
28 #[test]
29 fn filemap_works() {
30 let files = super::FileMap::new();
31 let css = files.get("./static/cache/bundle/css/main.css").unwrap();
32 println!("{}", css);
33 assert!(css.contains("/assets/bundle/css"));
34 }
35}