mirror of https://github.com/kdl-org/kdl-rs.git
Merge cd3cd621bc into ce82d2ce3e
This commit is contained in:
commit
39bc0a7693
|
|
@ -1126,7 +1126,7 @@ plugins {
|
||||||
welcome_screen true
|
welcome_screen true
|
||||||
}
|
}
|
||||||
filepicker location="zellij:strider" {
|
filepicker location="zellij:strider" {
|
||||||
cwd "\/"
|
cwd "/"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mouse_mode false
|
mouse_mode false
|
||||||
|
|
|
||||||
|
|
@ -334,10 +334,6 @@ impl KdlEntry {
|
||||||
// It's already a v1 string
|
// It's already a v1 string
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
} else if !s.starts_with("r#") {
|
|
||||||
// `/` is an escaped char in v2
|
|
||||||
let s = s.replace("\\/", "/"); // Maneuvering. Will fix in a sec.
|
|
||||||
s.replace('/', "\\/")
|
|
||||||
} else {
|
} else {
|
||||||
// We're all good! Let's move on.
|
// We're all good! Let's move on.
|
||||||
s.to_string()
|
s.to_string()
|
||||||
|
|
|
||||||
|
|
@ -24,3 +24,34 @@ fn build_and_format() {
|
||||||
"#
|
"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(feature = "v1")]
|
||||||
|
fn ensure_v1_does_not_over_escape_forward_slash() {
|
||||||
|
// Per the v1 spec, `\/` is a permitted escape but unescaped `/` is also
|
||||||
|
// legal. ensure_v1 should not introduce unnecessary `\/` escapes.
|
||||||
|
let input = "node \"a/b/c\"\n";
|
||||||
|
let mut doc = KdlDocument::parse_v1(input).unwrap();
|
||||||
|
doc.ensure_v1();
|
||||||
|
assert_eq!(doc.to_string(), input);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(feature = "v1")]
|
||||||
|
fn ensure_v2_strips_escaped_forward_slash() {
|
||||||
|
// `\/` is forbidden in v2, so ensure_v2 must convert it to a `/`.
|
||||||
|
let input = "node \"a\\/b\"\n";
|
||||||
|
let mut doc = KdlDocument::parse_v1(input).unwrap();
|
||||||
|
doc.ensure_v2();
|
||||||
|
assert_eq!(doc.to_string(), "node \"a/b\"\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(feature = "v1")]
|
||||||
|
fn ensure_v1_preserves_raw_string_with_backslash_slash() {
|
||||||
|
// In a raw string, `\/` is two literal characters, and should be kept as is.
|
||||||
|
let input = "node r#\"a\\/b\"#\n";
|
||||||
|
let mut doc = KdlDocument::parse_v1(input).unwrap();
|
||||||
|
doc.ensure_v1();
|
||||||
|
assert_eq!(doc.to_string(), input);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue