Repository: lsd-rs/lsd (Rust)

Issue:
lsd Not Displaying Some Icons Correctly
- os: MacOS Catalina 10.15.6
- `lsd --version`:  0.18.0
- `echo $TERM`: xterm-256color
- `echo $LS_COLORS`: 

## Expected behavior

For certain icons like Dockerfile, Gemfile, Rakefile, I'm expecting to see a special icon.
## Actual behavior
It shows a generic file, even though I see items in the code to show a special character. The special character shows in colorls, so I know my iTerm is set up properly. Here is a screenshot
![Screen Shot 2020-09-29 at 12 32 14 PM](https://user-images.githubusercontent.com/22504884/94608171-d9865c80-0251-11eb-99c3-96c3f4775fa7.png)




Discussion:

Patch:
diff --git a/src/icon.rs b/src/icon.rs
index e36cde451..f166c4dd2 100644
--- a/src/icon.rs
+++ b/src/icon.rs
@@ -75,13 +75,16 @@ impl Icons {
             "\u{fc29}" // "ﰩ"
         } else if let FileType::Special = file_type {
             "\u{f2dc}" // ""
-        } else if let Some(icon) = self.icons_by_name.get(name.file_name()) {
+        } else if let Some(icon) = self
+            .icons_by_name
+            .get(name.file_name().to_lowercase().as_str())
+        {
             // Use the known names.
             icon
-        } else if let Some(icon) = name
-            .extension()
-            .and_then(|extension| self.icons_by_extension.get(extension))
-        {
+        } else if let Some(icon) = name.extension().and_then(|extension| {
+            self.icons_by_extension
+                .get(extension.to_lowercase().as_str())
+        }) {
             // Use the known extensions.
             icon
         } else {
@@ -95,7 +98,9 @@ impl Icons {
     fn get_default_icons_by_name() -> HashMap<&'static str, &'static str> {
         let mut m = HashMap::new();
 
-        m.insert(".Trash", "\u{f1f8}"); // ""
+        // Note: filenames must be lower-case
+
+        m.insert(".trash", "\u{f1f8}"); // ""
         m.insert(".atom", "\u{e764}"); // ""
         m.insert(".bashprofile", "\u{e615}"); // ""
         m.insert(".bashrc", "\u{f489}"); // ""
@@ -136,6 +141,8 @@ impl Icons {
     fn get_default_icons_by_extension() -> HashMap<&'static str, &'static str> {
         let mut m = HashMap::new();
 
+        // Note: extensions must be lower-case
+
         m.insert("7z", "\u{f410}"); // ""
         m.insert("apk", "\u{e70e}"); // ""
         m.insert("avi", "\u{f03d}"); // ""


Test patch:
diff --git a/tests/integration.rs b/tests/integration.rs
index 65fcf3409..8dbf5023b 100644
--- a/tests/integration.rs
+++ b/tests/integration.rs
@@ -404,3 +404,67 @@ fn cmd() -> Command {
 fn tempdir() -> assert_fs::TempDir {
     assert_fs::TempDir::new().unwrap()
 }
+
+#[cfg(unix)]
+#[test]
+fn test_lower_case_name_icon_match() {
+    let dir = tempdir();
+    dir.child(".trash").touch().unwrap();
+    let test_file = dir.path().join(".trash");
+
+    cmd()
+        .arg("--icon")
+        .arg("always")
+        .arg("--ignore-config")
+        .arg(test_file)
+        .assert()
+        .stdout(predicate::str::contains("\u{f1f8}"));
+}
+
+#[cfg(unix)]
+#[test]
+fn test_upper_case_name_icon_match() {
+    let dir = tempdir();
+    dir.child(".TRASH").touch().unwrap();
+    let test_file = dir.path().join(".TRASH");
+
+    cmd()
+        .arg("--icon")
+        .arg("always")
+        .arg("--ignore-config")
+        .arg(test_file)
+        .assert()
+        .stdout(predicate::str::contains("\u{f1f8}"));
+}
+
+#[cfg(unix)]
+#[test]
+fn test_lower_case_ext_icon_match() {
+    let dir = tempdir();
+    dir.child("test.7z").touch().unwrap();
+    let test_file = dir.path().join("test.7z");
+
+    cmd()
+        .arg("--icon")
+        .arg("always")
+        .arg("--ignore-config")
+        .arg(test_file)
+        .assert()
+        .stdout(predicate::str::contains("\u{f410}"));
+}
+
+#[cfg(unix)]
+#[test]
+fn test_upper_case_ext_icon_match() {
+    let dir = tempdir();
+    dir.child("test.7Z").touch().unwrap();
+    let test_file = dir.path().join("test.7Z");
+
+    cmd()
+        .arg("--icon")
+        .arg("always")
+        .arg("--ignore-config")
+        .arg(test_file)
+        .assert()
+        .stdout(predicate::str::contains("\u{f410}"));
+}