Function normalize_path

pub fn normalize_path(path: &str) -> Result<Cow<'_, str>, AssetError>
Expand description

Normalize a relative authoring path without consulting the filesystem.

Backslashes become slashes, empty and . components are removed, and case is preserved. Absolute paths, drive prefixes, .. components (even within the root), non-ASCII names and normalized paths over 240 bytes are rejected. Already canonical paths are borrowed; normalization allocates at most 240 bytes. This is opt-in: Bundle::insert and Bundle::decode remain strict.

use ferravex_engine::assets::{normalize_path, Bundle};
let mut bundle = Bundle::default();
let path = normalize_path(r".\textures\\flat.rgba")?;
assert_eq!(path, "textures/flat.rgba");
bundle.insert(&path, &[255, 0, 0, 255])?;
assert!(normalize_path("textures/../secret").is_err());