Skip to content

Commit 5bf5313

Browse files
committed
fix: normalize absolute path
Signed-off-by: devjow <me@devjow.com>
1 parent ffbaa1c commit 5bf5313

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

gts-cli/src/gen_common.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,16 @@ pub fn safe_canonicalize_nonexistent(path: &Path) -> Result<PathBuf> {
221221
}
222222
}
223223

224+
// Normalize to an absolute path so that canonical_ancestor is always absolute.
225+
// This ensures starts_with(sandbox_root) comparisons work when the caller
226+
// passes a relative output directory.
227+
let path = if path.is_absolute() {
228+
path.to_path_buf()
229+
} else {
230+
std::env::current_dir()?.join(path)
231+
};
232+
let path = path.as_path();
233+
224234
if path.exists() {
225235
return Ok(path.canonicalize()?);
226236
}

0 commit comments

Comments
 (0)