use std::path::Path;
pub fn sanitize_tsv(s: &str) -> String {
if s.contains(['\t', '\n', '\r']) {
s.replace(['\t', '\n', '\r'], " ")
} else {
s.to_string()
}
}
pub fn display_path(path: &Path) -> String {
let p = if path.is_absolute() {
std::env::current_dir()
.ok()
.and_then(|cwd| path.strip_prefix(&cwd).ok())
.unwrap_or(path)
} else {
path
};
p.display().to_string()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn tsv_fields_lose_separators() {
assert_eq!(sanitize_tsv("a\tb\nc"), "a b c");
assert_eq!(sanitize_tsv("plain"), "plain");
}
}