Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nmattia committed Oct 27, 2023
1 parent 9f3d964 commit c25964d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/internet_identity/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,9 @@ fn collect_assets_from_dir(dir: &Dir) -> Vec<(String, Vec<u8>, ContentEncoding,
// TODO: add canister/lightweight test to ensure assets are loaded up
// & certified successfully
for asspath in asspaths {
println!("/{}", asspath);
// TODO: don't clone content
assets.push((
format!("/{}", asspath),
asspath,
content.clone(),
encoding,
content_type,
Expand Down Expand Up @@ -313,9 +312,10 @@ fn file_extension<'a>(asset: &'a File) -> &'a str {
fn filepath_to_asset_paths(file_path: String) -> Vec<String> {
// TODO: error out if starting with /?
// TODO: explain why not splitting by system path sep
// TODO: explain always return starting with /
let parts: Vec<&str> = file_path.split('/').collect();

match parts.split_last() {
let paths = match parts.split_last() {
None => {
vec!["Error, TODO".to_string()]
}
Expand All @@ -329,9 +329,9 @@ fn filepath_to_asset_paths(file_path: String) -> Vec<String> {
format!("{prefix}/"),
format!("{prefix}/index.html"),
]
} else if let Some(path) = last.strip_suffix(".html") {
} else if let Some(page) = last.strip_suffix(".html") {
let mut elements = elements.to_vec();
elements.push(path);
elements.push(page);
let prefix = elements.join("/").to_string();
vec![
format!("{prefix}"),
Expand All @@ -350,7 +350,9 @@ fn filepath_to_asset_paths(file_path: String) -> Vec<String> {
vec![prefix]
}
}
}
};

paths.into_iter().map(|path| format!("/{path}")).collect()
}

#[test]
Expand Down

0 comments on commit c25964d

Please sign in to comment.