bevyengine / bevyengine/bevy

`AssetPath` ignores source and label when parsing `Path` and `PathBuf`

Open
#11,945 3 comments 0 reactions 0 assignees View on GitHub
A-Assets C-Bug C-Usability
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## Bevy version

0.13

## What you did

```rust
use bevy::asset::AssetPath;

fn main() {
let path = std::path::Path::new("custom://some/custom/path#with_label");
let asset_path = AssetPath::from_path(path);
println!(
"source: {:?}, path: {:?}, label: {:?}",
asset_path.source(),
asset_path.path(),
asset_path.label()
);
let asset_path = AssetPath::parse("custom:://some/custom/path#with_label");
println!(
"source: {:?}, path: {:?}, label: {:?}",
asset_path.source(),
asset_path.path(),
asset_path.label()
);
}
```

## What went wrong

First println:
```
source: Default, path: "custom://some/custom/path#with_label", label: None
```

Second println:
```
source: Name("custom:"), path: "some/custom/path", label: Some("with_label")
```

## Additional information

`Path` and `PathBuf` are useful to deal with paths due to extensions and components management without having to deal with Windows vs Unix separator, but when converting to `AssetPath` it just ignores `source` and `label` and ends up with an invalid path.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.