Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nmattia committed Oct 24, 2023
1 parent b8a5920 commit 5bfb5df
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/internet_identity/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,15 @@ fn collect_assets_from_dir(dir: &Dir) -> Vec<(String, Vec<u8>, ContentEncoding,
),
};

let asspaths = filepath_to_asset_paths("/".to_string() + asset.path().to_str().unwrap());
let asspaths = filepath_to_asset_paths(asset.path().to_str().unwrap().to_string());

// TODO: remove / prefix
// 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.to_string()), content.clone(), encoding, content_type));
assets.push((format!("/{}", asspath), content.clone(), encoding, content_type));

}
}
Expand Down Expand Up @@ -308,6 +308,7 @@ fn file_extension<'a>(asset: &'a File) -> &'a str {
/// * map **/<foo>.html to **/foo
/// * map **/<foo>.js.gz to **/<foo>.js
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
let parts: Vec<&str> = file_path.split('/').collect();

Expand Down Expand Up @@ -383,6 +384,7 @@ fn test_filepath_asset_paths() {
],
);

assert_gen_paths("index.css".to_string(), vec!["index.css".to_string()]);
assert_gen_paths("foo.bar.gz".to_string(), vec!["foo.bar".to_string()]);

assert_gen_paths(
Expand Down

0 comments on commit 5bfb5df

Please sign in to comment.