Skip to content

Commit

Permalink
Merge pull request #9 from OpenXbox/fix/auth_titlehub
Browse files Browse the repository at this point in the history
fix: auth_titlehub - Strip atom_type from leading path seperator too
  • Loading branch information
tuxuser authored Jan 14, 2025
2 parents 67e8970 + 6a27380 commit 230ba61
Showing 1 changed file with 26 additions and 0 deletions.
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

0 comments on commit 230ba61

Please sign in to comment.