mirror of
https://github.com/storytold/deckcraft.git
synced 2026-10-31 05:56:55 -06:00
Merge pull request #1352
This commit is contained in:
@@ -297,7 +297,7 @@ fn percent_decode(s: &str) -> String {
|
||||
|
||||
/// Resolve a relative target against a base directory into a part name.
|
||||
pub fn resolve(base: &str, target: &str) -> String {
|
||||
let target = percent_decode(target.split('#').next().unwrap_or(""));
|
||||
let target = percent_decode(target.split('#').next().unwrap_or("")).replace('\\', "/");
|
||||
let target = target.as_str();
|
||||
let mut segs: Vec<&str> = if target.starts_with('/') { vec![] } else { base.split('/').filter(|s| !s.is_empty()).collect() };
|
||||
for s in target.split('/') {
|
||||
@@ -507,6 +507,12 @@ mod tests {
|
||||
assert!(p.xml_bytes("missing.xml").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resolve_backslash_target() {
|
||||
assert_eq!(resolve("ppt/slides", "..\\media\\image1.png"), "ppt/media/image1.png");
|
||||
assert_eq!(resolve("ppt/slides", "\\ppt\\media\\a.png"), "ppt/media/a.png");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn path_resolution() {
|
||||
assert_eq!(resolve("ppt/slides", "../media/image1.png"), "ppt/media/image1.png");
|
||||
|
||||
Reference in New Issue
Block a user