fix(windows): fix #4251 ensure case-insensitive checks for app extensions

* Updated `GetAppExtensions` and `ParseAppInfo` methods to perform case-insensitive checks for `.lnk` and `.exe` file extensions.
* This change improves compatibility with file systems that are case-sensitive.
This commit is contained in:
qianlifeng 2025-07-29 13:07:26 +08:00
parent a387b73ceb
commit 250f3607f6
2 changed files with 5 additions and 4 deletions

View File

@ -434,7 +434,7 @@ func (a *ApplicationPlugin) getAppPaths(ctx context.Context, appDirectories []ap
for _, entry := range appPath {
isExtensionMatch := lo.ContainsBy(appExtensions, func(ext string) bool {
return strings.HasSuffix(entry.Name(), fmt.Sprintf(".%s", ext))
return strings.HasSuffix(strings.ToLower(entry.Name()), fmt.Sprintf(".%s", ext))
})
if isExtensionMatch {
appPaths = append(appPaths, path.Join(dir.Path, entry.Name()))

View File

@ -113,10 +113,11 @@ func (a *WindowsRetriever) GetAppExtensions(ctx context.Context) []string {
}
func (a *WindowsRetriever) ParseAppInfo(ctx context.Context, path string) (appInfo, error) {
if strings.HasSuffix(path, ".lnk") {
lowerPath := strings.ToLower(path)
if strings.HasSuffix(lowerPath, ".lnk") {
return a.parseShortcut(ctx, path)
}
if strings.HasSuffix(path, ".exe") {
if strings.HasSuffix(lowerPath, ".exe") {
return a.parseExe(ctx, path)
}
@ -132,7 +133,7 @@ func (a *WindowsRetriever) parseShortcut(ctx context.Context, appPath string) (a
a.api.Log(ctx, plugin.LogLevelInfo, fmt.Sprintf("Resolved shortcut %s -> %s", appPath, targetPath))
if targetPath == "" || !strings.HasSuffix(targetPath, ".exe") {
if targetPath == "" || !strings.HasSuffix(strings.ToLower(targetPath), ".exe") {
return appInfo{}, errors.New("no target path found or not an exe file")
}