diff --git a/crates/nu-command/src/filesystem/open.rs b/crates/nu-command/src/filesystem/open.rs index a1d0ca241..bc8a02e79 100644 --- a/crates/nu-command/src/filesystem/open.rs +++ b/crates/nu-command/src/filesystem/open.rs @@ -171,12 +171,11 @@ impl Command for Open { metadata: None, trim_end_newline: false, }; - let ext = if raw { None } else { path.extension() - .map(|name| name.to_string_lossy().to_string()) + .map(|name| name.to_string_lossy().to_string().to_lowercase()) }; if let Some(ext) = ext { diff --git a/crates/nu-command/tests/commands/open.rs b/crates/nu-command/tests/commands/open.rs index 5a1b3b2e9..b218f1f67 100644 --- a/crates/nu-command/tests/commands/open.rs +++ b/crates/nu-command/tests/commands/open.rs @@ -1,8 +1,39 @@ use nu_test_support::fs::Stub::EmptyFile; +use nu_test_support::fs::Stub::FileWithContent; use nu_test_support::fs::Stub::FileWithContentToBeTrimmed; use nu_test_support::playground::Playground; use nu_test_support::{nu, pipeline}; +#[test] +fn parses_file_with_uppercase_extension() { + Playground::setup("open_test_uppercase_extension", |dirs, sandbox| { + sandbox.with_files(vec![FileWithContent( + "nu.zion.JSON", + r#"{ + "glossary": { + "GlossDiv": { + "GlossList": { + "GlossEntry": { + "ID": "SGML" + } + } + } + } + }"#, + )]); + + let actual = nu!( + cwd: dirs.test(), pipeline( + r#" + open nu.zion.JSON + | get glossary.GlossDiv.GlossList.GlossEntry.ID + "# + )); + + assert_eq!(actual.out, "SGML"); + }) +} + #[test] fn parses_csv() { Playground::setup("open_test_1", |dirs, sandbox| {