I have this code:
fn main() {
let root = std::path::Path::new("resources/");
let uri = std::path::Path::new("/js/main.js");
let path = root.join(uri);
assert_eq!(path.to_str(), Some("resources/js/main.js"));
}
As stated in Why does joining paths completely replace the original path in Rust?, this will fail because of the first slash in /js/main.js
. It will work only without the slash in the beginning.
Is there a way to avoid this behaviour, even if the slash is put?