Skip to content
Open
Changes from all 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
26 changes: 25 additions & 1 deletion crates/bevy_asset/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,13 @@ pub(crate) fn normalize_path(path: &Path) -> PathBuf {
if elt == "." {
// Skip
} else if elt == ".." {
if !result_path.pop() {
// Note: If the result_path ends in `..`, Path::file_name returns None, so we'll end up
// preserving it.
if result_path.file_name().is_some() {
// This assert is just a sanity check - we already know the path has a file_name, so
// we know there is something to pop.
assert!(result_path.pop());
} else {
// Preserve ".." if insufficient matches (per RFC 1808).
result_path.push(elt);
}
Expand Down Expand Up @@ -996,6 +1002,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