diff --git a/crates/nu-cli/src/repl.rs b/crates/nu-cli/src/repl.rs index ab926b2f40..cbb48e905c 100644 --- a/crates/nu-cli/src/repl.rs +++ b/crates/nu-cli/src/repl.rs @@ -820,16 +820,29 @@ fn looks_like_path(orig: &str) -> bool { || orig.starts_with('~') || orig.starts_with('/') || orig.starts_with('\\') + || orig.ends_with(std::path::MAIN_SEPARATOR) } +#[cfg(windows)] #[test] fn looks_like_path_windows_drive_path_works() { - let on_windows = cfg!(windows); - assert_eq!(looks_like_path("C:"), on_windows); - assert_eq!(looks_like_path("D:\\"), on_windows); - assert_eq!(looks_like_path("E:/"), on_windows); - assert_eq!(looks_like_path("F:\\some_dir"), on_windows); - assert_eq!(looks_like_path("G:/some_dir"), on_windows); + assert!(looks_like_path("C:")); + assert!(looks_like_path("D:\\")); + assert!(looks_like_path("E:/")); + assert!(looks_like_path("F:\\some_dir")); + assert!(looks_like_path("G:/some_dir")); +} + +#[cfg(windows)] +#[test] +fn trailing_slash_looks_like_path() { + assert!(looks_like_path("foo\\")) +} + +#[cfg(not(windows))] +#[test] +fn trailing_slash_looks_like_path() { + assert!(looks_like_path("foo/")) } #[test]