mirror of https://github.com/Wox-launcher/Wox
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:
parent
a387b73ceb
commit
250f3607f6
|
@ -434,7 +434,7 @@ func (a *ApplicationPlugin) getAppPaths(ctx context.Context, appDirectories []ap
|
||||||
|
|
||||||
for _, entry := range appPath {
|
for _, entry := range appPath {
|
||||||
isExtensionMatch := lo.ContainsBy(appExtensions, func(ext string) bool {
|
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 {
|
if isExtensionMatch {
|
||||||
appPaths = append(appPaths, path.Join(dir.Path, entry.Name()))
|
appPaths = append(appPaths, path.Join(dir.Path, entry.Name()))
|
||||||
|
|
|
@ -113,10 +113,11 @@ func (a *WindowsRetriever) GetAppExtensions(ctx context.Context) []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *WindowsRetriever) ParseAppInfo(ctx context.Context, path string) (appInfo, error) {
|
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)
|
return a.parseShortcut(ctx, path)
|
||||||
}
|
}
|
||||||
if strings.HasSuffix(path, ".exe") {
|
if strings.HasSuffix(lowerPath, ".exe") {
|
||||||
return a.parseExe(ctx, path)
|
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))
|
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")
|
return appInfo{}, errors.New("no target path found or not an exe file")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue