Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion crates/bevy_asset/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,12 @@ pub(crate) fn normalize_path(path: &Path) -> PathBuf {
if elt == "." {
// Skip
} else if elt == ".." {
if !result_path.pop() {
if let Some(file_name) = result_path.file_name()
// Don't collapse .. with another ..
&& file_name != ".."
{
assert!(result_path.pop());
} else {
// Preserve ".." if insufficient matches (per RFC 1808).
result_path.push(elt);
}
Expand Down Expand Up @@ -996,6 +1001,24 @@ mod tests {
);
}

#[test]
fn resolve_embed_relative_to_external_path() {
let base = AssetPath::from("../../a/b.gltf");
assert_eq!(
base.resolve_embed("c.bin").unwrap(),
AssetPath::from("../../a/c.bin")
);
}

#[test]
fn resolve_relative_to_external_path() {
let base = AssetPath::from("../../a/b.gltf");
assert_eq!(
base.resolve("c.bin").unwrap(),
AssetPath::from("../../a/b.gltf/c.bin")
);
}

#[test]
fn test_get_extension() {
let result = AssetPath::from("http://a.tar.gz#Foo");
Expand Down