Skip to content

Commit b6bafd2

Browse files
branchseerclaude
andcommitted
fix: Windows path handling in snapshot redaction
- Handle both backslash and forward slash variants of paths for workspace_root and manifest_dir redaction - Normalize PATH separator from ; (Windows) to : (Unix) for cross-platform consistency Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 858b57b commit b6bafd2

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

  • crates/vite_task_bin/tests/test_snapshots

crates/vite_task_bin/tests/test_snapshots/redact.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,32 @@ pub fn redact_e2e_output(mut output: String, workspace_root: &str) -> String {
7373
pub fn redact_snapshot(value: &impl Serialize, workspace_root: &str) -> serde_json::Value {
7474
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
7575
let mut json_value = serde_json::to_value(value).unwrap();
76+
77+
// On Windows, paths might use either backslashes or forward slashes
78+
// Try both variants for workspace_root and manifest_dir
79+
let workspace_root_forward = workspace_root.replace('\\', "/");
80+
let manifest_dir_forward = manifest_dir.replace('\\', "/");
81+
7682
redact_string_in_json(
7783
&mut json_value,
78-
&[(workspace_root, "<workspace>"), (manifest_dir.as_str(), "<manifest_dir>")],
84+
&[
85+
(workspace_root, "<workspace>"),
86+
(workspace_root_forward.as_str(), "<workspace>"),
87+
(manifest_dir.as_str(), "<manifest_dir>"),
88+
(manifest_dir_forward.as_str(), "<manifest_dir>"),
89+
],
7990
);
8091

92+
// Normalize PATH separators for cross-platform consistency (Windows uses ; Unix uses :)
93+
visit_json(&mut json_value, &mut |v| {
94+
let serde_json::Value::Object(map) = v else {
95+
return;
96+
};
97+
if let Some(serde_json::Value::String(path)) = map.get_mut("PATH") {
98+
*path = path.replace(';', ":");
99+
}
100+
});
101+
81102
// Normalize Windows program names and paths by stripping common extensions for cross-platform consistency
82103
visit_json(&mut json_value, &mut |v| {
83104
let serde_json::Value::Object(map) = v else {

0 commit comments

Comments
 (0)