Skip to main content

normalize_path

Function normalize_path 

Source
pub fn normalize_path(workspace_root: &PathBuf, path: &str) -> PathBuf
Expand description

Normalize a path relative to the workspace root.

Handles the double-prefix bug where the model passes an absolute path like “/opt/pawan/grind/opt/pawan/grind/foo.rs” — it joined the workspace root with an absolute path instead of a relative one. We detect the workspace root appearing twice and collapse to the second occurrence.

§Parameters

  • workspace_root: The root directory of the workspace
  • path: The path to normalize (can be relative or absolute)

§Returns

The normalized path as a PathBuf