diff options
author | Nadrieril | 2019-08-31 22:37:48 +0200 |
---|---|---|
committer | Nadrieril | 2019-08-31 22:37:48 +0200 |
commit | befc4cda44a4f1e26aa0a301dfc92b455cbcbf18 (patch) | |
tree | e7866fde1008271c41f3f35fc48ae918a74f67d0 /dhall_syntax/src/printer.rs | |
parent | 774d1affe13b50945517ccc43f9d4e771841e4a2 (diff) |
Don't URL-decode path segments
Diffstat (limited to '')
-rw-r--r-- | dhall_syntax/src/printer.rs | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/dhall_syntax/src/printer.rs b/dhall_syntax/src/printer.rs index 8571d11..f3dc648 100644 --- a/dhall_syntax/src/printer.rs +++ b/dhall_syntax/src/printer.rs @@ -360,15 +360,9 @@ impl<SubExpr: Display> Display for Import<SubExpr> { use FilePrefix::*; use ImportLocation::*; use ImportMode::*; - let fmt_remote_path_component = |s: &str| -> String { - use percent_encoding::{ - utf8_percent_encode, PATH_SEGMENT_ENCODE_SET, - }; - utf8_percent_encode(s, PATH_SEGMENT_ENCODE_SET).to_string() - }; - let fmt_local_path_component = |s: &str| -> String { + let quote_if_needed = |s: &str| -> String { if s.chars().all(|c| c.is_ascii_alphanumeric()) { - s.to_owned() + s.to_string() } else { format!("\"{}\"", s) } @@ -383,19 +377,13 @@ impl<SubExpr: Display> Display for Import<SubExpr> { Absolute => "", }; write!(f, "{}/", prefix)?; - let path: String = path - .iter() - .map(|c| fmt_local_path_component(c.as_ref())) - .join("/"); + let path: String = + path.iter().map(|c| quote_if_needed(&*c)).join("/"); f.write_str(&path)?; } Remote(url) => { write!(f, "{}://{}/", url.scheme, url.authority,)?; - let path: String = url - .path - .iter() - .map(|c| fmt_remote_path_component(c.as_ref())) - .join("/"); + let path: String = url.path.iter().join("/"); f.write_str(&path)?; if let Some(q) = &url.query { write!(f, "?{}", q)? |