Skip to content

[Fix] Steam Shortcuts / Make checkIfAlreadyAdded case-insensitive #3320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/backend/shortcuts/nonesteamgame/nonesteamgame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,17 @@ function hasParameterCaseInsensitive(object: ShortcutEntry, key: string) {
return Object.keys(object).some((k) => k.toLowerCase() === keyAsLowercase)
}

/** Return AppName property case insensitive
* @param {Object} object
* @returns Title of Shortcut Entry
*/
function getAppName(object: ShortcutEntry) {
const foundkey =
Object.keys(object).find((key) => key.toLowerCase() === 'appname') ??
'AppName'
return object[foundkey]
}

/**
* Check if the parsed object of a shortcuts.vdf is valid.
* @param object @see Partial<ShortcutObject>
Expand Down Expand Up @@ -184,7 +195,7 @@ function checkIfShortcutObjectIsValid(
*/
function checkIfAlreadyAdded(object: Partial<ShortcutObject>, title: string) {
const shortcuts = object.shortcuts ?? []
return shortcuts.findIndex((entry) => entry.AppName === title)
return shortcuts.findIndex((entry) => getAppName(entry) === title)
}

/**
Expand Down Expand Up @@ -419,7 +430,7 @@ async function removeNonSteamGame(props: {
const shortcutObj = content.shortcuts.at(index)!

const exe = shortcutObj.Exe
const appName = shortcutObj.AppName
const appName = getAppName(shortcutObj)

// remove
content.shortcuts.splice(index, 1)
Expand Down