Skip to content

Commit

Permalink
Clean up code and add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark McCaskey committed Oct 1, 2020
1 parent ad05114 commit 7612270
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions lib/wasi/src/state/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,17 +438,10 @@ impl PreopenDirBuilder {

/// Make this preopened directory appear to the WASI program as `alias`
pub fn alias(&mut self, alias: &str) -> &mut Self {
let alias = if let Some(first_byte) = alias.as_bytes().first() {
if *first_byte == b'/' {
&alias[1..]
} else {
alias
}
} else {
alias
}
.to_string();
self.alias = Some(alias);
// We mount at preopened dirs at `/` by default and multiple `/` in a row
// are equal to a single `/`.
let alias = alias.trim_start_matches(b'/');
self.alias = Some(alias.to_string());

self
}
Expand Down

0 comments on commit 7612270

Please sign in to comment.