diff --git a/src/internet_identity/src/assets.rs b/src/internet_identity/src/assets.rs index 1425ca4376..0a371cfed6 100644 --- a/src/internet_identity/src/assets.rs +++ b/src/internet_identity/src/assets.rs @@ -274,10 +274,9 @@ fn collect_assets_from_dir(dir: &Dir) -> Vec<(String, Vec, 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, @@ -313,9 +312,10 @@ fn file_extension<'a>(asset: &'a File) -> &'a str { fn filepath_to_asset_paths(file_path: String) -> Vec { // 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()] } @@ -329,9 +329,9 @@ fn filepath_to_asset_paths(file_path: String) -> Vec { 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}"), @@ -350,7 +350,9 @@ fn filepath_to_asset_paths(file_path: String) -> Vec { vec![prefix] } } - } + }; + + paths.into_iter().map(|path| format!("/{path}")).collect() } #[test]