Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/dfx/src/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,16 @@ pub fn construct() -> App<'static, 'static> {

fn get_asset_fn(assets: &AssetMap) -> String {
// Create the if/else series.
let mut if_else = String::new();
let mut cases = String::new();
assets.iter().for_each(|(filename, content)| {
if_else += format!(
r#"if (path == "{}") {par} return "{}"; {end};{endline}"#,
cases += format!(
r#"case "{}" "{}";{endline}"#,
filename,
content
.replace("\\", "\\\\")
.replace("\"", "\\\"")
.replace("\n", "\\n")
.replace("\r", ""),
par = "{",
end = "}",
endline = "\n"
)
.as_str();
Expand All @@ -53,11 +51,13 @@ fn get_asset_fn(assets: &AssetMap) -> String {
format!(
r#"
public query func __dfx_asset_path(path: Text): async Text {par}
{}
return "";
switch path {par}
{}
case _ {par}assert false; ""{end}
{end}
{end};
"#,
if_else,
cases,
par = "{",
end = "}"
)
Expand Down