Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: auth_titlehub - Strip atom_type from leading path seperator too #9

Merged
merged 1 commit into from
Jan 14, 2025
Merged
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: 26 additions & 0 deletions examples/src/bin/auth_titlehub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ pub fn assemble_filepath(root_path: &Path, atom_type: &str, path: &str) -> PathB
}
};

let atom_type = {
if let Some(stripped) = atom_type.strip_prefix("/") {
// Remove leading path seperator
stripped.to_string()
}
else {
atom_type.to_string()
}
};

let mut new_path = root_path.to_path_buf();
new_path.push(atom_type);
new_path.push(modified_path);
Expand Down Expand Up @@ -279,6 +289,14 @@ mod tests
"/root/filesystem/Data/save-container.bin",
assemble_filepath(&PathBuf::from_str("/root/filesystem").unwrap(), "Data", "saveEcontainerXbin,savedgame").as_os_str()
);
assert_eq!(
"/root/filesystem/Custom Input Config.json/save-container.bin",
assemble_filepath(&PathBuf::from_str("/root/filesystem").unwrap(), "/Custom Input Config.json", "saveEcontainerXbin,savedgame").as_os_str()
);
assert_eq!(
"/root/filesystem/Custom Input Config.json/save-container.bin",
assemble_filepath(&PathBuf::from_str("/root/filesystem").unwrap(), "Custom Input Config.json", "saveEcontainerXbin,savedgame").as_os_str()
);
}

#[cfg(target_os = "windows")]
Expand All @@ -292,6 +310,14 @@ mod tests
"C:\\some_dir\\Data\\save-container.bin",
assemble_filepath(&PathBuf::from_str("C:\\some_dir\\").unwrap(), "Data", "saveEcontainerXbin,savedgame").as_os_str()
);
assert_eq!(
"C:\\some_dir\\Custom Input Config.json\\save-container.bin",
assemble_filepath(&PathBuf::from_str("/root/filesystem").unwrap(), "/Custom Input Config.json", "saveEcontainerXbin,savedgame").as_os_str()
);
assert_eq!(
"C:\\some_dir\\Custom Input Config.json\\save-container.bin",
assemble_filepath(&PathBuf::from_str("/root/filesystem").unwrap(), "Custom Input Config.json", "saveEcontainerXbin,savedgame").as_os_str()
);
}

#[test]
Expand Down
Loading