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 7e097b4
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions lib/wasi/src/state/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,16 +438,9 @@ 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();
// 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);

self
Expand Down

0 comments on commit 7e097b4

Please sign in to comment.