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
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
### 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;
if let Some(file) = files.get_full_path(path) {
println!("{:?}", files.get(path));
Path::new(file).exists()
} else {
false

View file

@ -44,8 +44,8 @@ impl Files {
/// 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> {
if let Some(path) = self.map.get(path) {
//Some(&path[self.base_dir.len()..])
Some(&path)
Some(&path[self.base_dir.len()..])
// Some(&path)
} else {
None
}
@ -149,9 +149,9 @@ mod tests {
fn get_runner(path: &str, files: &Files) -> bool {
if let Some(file) = files.get(path) {
// let path = Path::new(&files.base_dir).join(&file[1..]);
println!("{}", &file);
let path = Path::new(&file);
let path = Path::new(&files.base_dir).join(&file[1..]);
//println!("{}", &file);
let path = Path::new(&path);
path.exists()
} else {
false