summaryrefslogtreecommitdiff
path: root/cli/deno_dir.rs
diff options
context:
space:
mode:
authorKevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com>2019-05-09 09:20:34 -0700
committerRyan Dahl <ry@tinyclouds.org>2019-05-09 12:20:34 -0400
commitd9cdc6788b1ed89d7f3b2daf9da7e4a9f664e424 (patch)
tree8b007590b9bf39c7292355dd5b0f3a41b5d1c0a5 /cli/deno_dir.rs
parent2edee3367dc9003b721cf87ca57e820c7acf7b25 (diff)
fix: support relative path for whitelisting (#2317)
Using `std::fs::canonicalize` to expand path to full existing path, such that later attempt to loop-pop and compare path segment would work.
Diffstat (limited to 'cli/deno_dir.rs')
-rw-r--r--cli/deno_dir.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/cli/deno_dir.rs b/cli/deno_dir.rs
index 4bca1117a..9d83ad044 100644
--- a/cli/deno_dir.rs
+++ b/cli/deno_dir.rs
@@ -896,6 +896,14 @@ pub fn resolve_file_url(
Ok(j)
}
+pub fn resolve_path(path: &str) -> Result<(PathBuf, String), DenoError> {
+ let url = resolve_file_url(path.to_string(), ".".to_string())
+ .map_err(DenoError::from)?;
+ let path = url.to_file_path().unwrap();
+ let path_string = path.to_str().unwrap().to_string();
+ Ok((path, path_string))
+}
+
#[cfg(test)]
mod tests {
use super::*;