Normalize a user-provided memory name to a full vault path. Ensures the path starts with `memory/` and ends with `.md`.
(name: &str)
| 256 | /// |
| 257 | /// Ensures the path starts with `memory/` and ends with `.md`. |
| 258 | fn normalize_memory_path(name: &str) -> String { |
| 259 | let name = if name.starts_with("memory/") { |
| 260 | name.to_string() |
| 261 | } else { |
| 262 | format!("memory/{}", name) |
| 263 | }; |
| 264 | if name.ends_with(".md") { |
| 265 | name |
| 266 | } else { |
| 267 | format!("{}.md", name) |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | // Tests |
| 272 |