Skip to content

Commit 5f1f185

Browse files
authored
Fix: Fixed issue where folders ending with '.url' couldn't be opened. (#17101)
1 parent d4e4ebf commit 5f1f185

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/Files.Shared/Helpers/FileExtensionHelpers.cs

+10-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License.
33

44
using System;
5+
using System.IO;
56
using System.Linq;
67

78
namespace Files.Shared.Helpers
@@ -22,7 +23,12 @@ public static bool HasExtension(string? filePathToCheck, params string[] extensi
2223
if (string.IsNullOrWhiteSpace(filePathToCheck))
2324
return false;
2425

25-
return extensions.Any(ext => filePathToCheck.EndsWith(ext, StringComparison.OrdinalIgnoreCase));
26+
// Don't check folder paths to avoid issues
27+
// https://github.com/files-community/Files/issues/17094
28+
if (Directory.Exists(filePathToCheck))
29+
return false;
30+
31+
return extensions.Any(ext => Path.GetExtension(filePathToCheck).Equals(ext, StringComparison.OrdinalIgnoreCase));
2632
}
2733

2834
/// <summary>
@@ -54,7 +60,7 @@ public static bool IsAudioFile(string? fileExtensionToCheck)
5460
{
5561
return HasExtension(fileExtensionToCheck, ".mp3", ".m4a", ".wav", ".wma", ".aac", ".adt", ".adts", ".cda", ".flac");
5662
}
57-
63+
5864
/// <summary>
5965
/// Check if the file extension is a video file.
6066
/// </summary>
@@ -213,7 +219,7 @@ public static bool IsVhdFile(string? fileExtensionToCheck)
213219
{
214220
return HasExtension(fileExtensionToCheck, ".vhd", ".vhdx");
215221
}
216-
222+
217223
/// <summary>
218224
/// Check if the file extension is a screen saver file.
219225
/// </summary>
@@ -256,7 +262,7 @@ public static bool IsScriptFile(string? filePathToCheck)
256262
{
257263
return HasExtension(filePathToCheck, ".py", ".ahk");
258264
}
259-
265+
260266
/// <summary>
261267
/// Check if the file extension is a system file.
262268
/// </summary>

0 commit comments

Comments
 (0)