Skip to content

Commit fe53987

Browse files
jamesadevineCopilot
andcommitted
fix: detect Unix-style absolute paths on Windows in normalize_relative_path
On Windows, Path::is_absolute() does not recognise Unix-style paths like /home/user/agents/ctf.md (no drive letter). These were falling through to the relative path branch and being emitted verbatim, producing paths like '{{ workspace }}//home/user/agents/ctf.md'. Add a supplementary starts_with('/') check so these paths are correctly treated as absolute and fall back to filename-only. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 7d0e541 commit fe53987

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/compile/common.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,12 @@ pub fn generate_pipeline_path(output_path: &std::path::Path) -> String {
564564
/// Callers are responsible for ensuring the path does not traverse outside the
565565
/// repository checkout.
566566
fn normalize_relative_path(path: &std::path::Path) -> Option<String> {
567-
if path.is_absolute() {
567+
// Detect absolute paths — including Unix-style paths on Windows (which
568+
// `Path::is_absolute()` does not recognise because they lack a drive letter).
569+
let looks_absolute =
570+
path.is_absolute() || path.to_string_lossy().starts_with('/');
571+
572+
if looks_absolute {
568573
// Try to make the path relative to the nearest git repo root so that
569574
// directory structure (e.g. `agents/ctf.md`) is preserved even when
570575
// the user invokes the compiler with an absolute path.

0 commit comments

Comments
 (0)