Skip to main content

normalize_path

Function normalize_path 

Source
pub fn normalize_path(path: &str) -> Cow<'_, str>
Expand description

Normalize a path for consistent comparison

Ensures paths have a leading slash and no trailing slash (unless root). Returns Cow<str> to avoid allocation when path is already normalized.

ยงExamples

use gpui_navigator::normalize_path;

assert_eq!(normalize_path("/dashboard"), "/dashboard");
assert_eq!(normalize_path("dashboard"), "/dashboard");
assert_eq!(normalize_path("/dashboard/"), "/dashboard");
assert_eq!(normalize_path("/"), "/");
assert_eq!(normalize_path(""), "/");