path without prefix bug fix

This commit is contained in:
Aravinth Manivannan 2021-04-30 21:27:56 +05:30
parent ceb3099530
commit 874dec8180
Signed by: realaravinth
GPG key ID: AD9F0F08E855ED88
4 changed files with 11 additions and 6 deletions

View file

@ -9,6 +9,10 @@
`CACHE_BUSTER_DATA_FILE`(`./src/cache_buster_data.json`) and the user `CACHE_BUSTER_DATA_FILE`(`./src/cache_buster_data.json`) and the user
is requested to read and pass the value to `File::new()` is requested to read and pass the value to `File::new()`
### Fixed:
- `Files::get()` now behaves as it is described in the documentation
## 0.1.1 ## 0.1.1
### Added: ### Added:

File diff suppressed because one or more lines are too long

View file

@ -21,6 +21,7 @@ fn get_full_path_runner(path: &str, files: &Files) -> bool {
use std::path::Path; use std::path::Path;
if let Some(file) = files.get_full_path(path) { if let Some(file) = files.get_full_path(path) {
println!("{:?}", files.get(path));
Path::new(file).exists() Path::new(file).exists()
} else { } else {
false false

View file

@ -44,8 +44,8 @@ impl Files {
/// output `/test.randomhash.svg`. For full path, see [get_full_path][Self::get_full_path]. /// output `/test.randomhash.svg`. For full path, see [get_full_path][Self::get_full_path].
pub fn get<'a>(&'a self, path: &'a str) -> Option<&'a str> { pub fn get<'a>(&'a self, path: &'a str) -> Option<&'a str> {
if let Some(path) = self.map.get(path) { if let Some(path) = self.map.get(path) {
//Some(&path[self.base_dir.len()..]) Some(&path[self.base_dir.len()..])
Some(&path) // Some(&path)
} else { } else {
None None
} }
@ -149,9 +149,9 @@ mod tests {
fn get_runner(path: &str, files: &Files) -> bool { fn get_runner(path: &str, files: &Files) -> bool {
if let Some(file) = files.get(path) { if let Some(file) = files.get(path) {
// let path = Path::new(&files.base_dir).join(&file[1..]); let path = Path::new(&files.base_dir).join(&file[1..]);
println!("{}", &file); //println!("{}", &file);
let path = Path::new(&file); let path = Path::new(&path);
path.exists() path.exists()
} else { } else {
false false