From befc4cda44a4f1e26aa0a301dfc92b455cbcbf18 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 31 Aug 2019 22:37:48 +0200 Subject: Don't URL-decode path segments --- dhall_syntax/src/printer.rs | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'dhall_syntax/src/printer.rs') 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 Display for Import { 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 Display for Import { 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)? -- cgit v1.2.3