diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-06-24 13:28:37 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2021-07-02 16:15:01 +0200 |
| commit | 812a23b48b39b0da4f6c2ae5b4e0f856ff3b2df4 (patch) | |
| tree | f1b41a73c8a8210c003ea9b1154b7ff7fa315381 /gui/src | |
| parent | 7fed4ad4c1d66c8fa4fab0e870ed2fdc4e941d74 (diff) | |
| download | mullvadvpn-812a23b48b39b0da4f6c2ae5b4e0f856ff3b2df4.tar.xz mullvadvpn-812a23b48b39b0da4f6c2ae5b4e0f856ff3b2df4.zip | |
Make application path comparison case insensitive
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/main/windows-split-tunneling.ts | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/gui/src/main/windows-split-tunneling.ts b/gui/src/main/windows-split-tunneling.ts index 5dcc861c22..88a32f9850 100644 --- a/gui/src/main/windows-split-tunneling.ts +++ b/gui/src/main/windows-split-tunneling.ts @@ -74,7 +74,10 @@ export async function getApplications(options: { .filter( (application) => options.applicationPaths === undefined || - options.applicationPaths.includes(application.absolutepath), + options.applicationPaths.find( + (applicationPath) => + applicationPath.toLowerCase() === application.absolutepath.toLowerCase(), + ) !== undefined, ) .sort((a, b) => a.name.localeCompare(b.name)); @@ -107,11 +110,11 @@ async function updateShortcutCache(): Promise<void> { const shortcuts: ShortcutDetails[] = []; for (const shortcut of resolvedLinks) { if ( - APPLICATION_ALLOW_LIST.includes(path.basename(shortcut.target)) || + APPLICATION_ALLOW_LIST.includes(path.basename(shortcut.target.toLowerCase())) || (await importsDll(shortcut.target, 'WS2_32.dll')) ) { shortcuts.push(shortcut); - shortcutCache[shortcut.target] = shortcut; + shortcutCache[shortcut.target.toLowerCase()] = shortcut; } } } @@ -121,11 +124,12 @@ async function updateApplicationCache(): Promise<void> { await Promise.all( shortcuts.map(async (shortcut) => { - if (applicationCache[shortcut.target] === undefined) { - applicationCache[shortcut.target] = await convertToSplitTunnelingApplication(shortcut); + const lowercaseTarget = shortcut.target.toLowerCase(); + if (applicationCache[lowercaseTarget] === undefined) { + applicationCache[lowercaseTarget] = await convertToSplitTunnelingApplication(shortcut); } - return applicationCache[shortcut.target]; + return applicationCache[lowercaseTarget]; }), ); } @@ -133,8 +137,10 @@ async function updateApplicationCache(): Promise<void> { // Add excluded apps that are missing from the shortcut cache to it function addApplicationToAdditionalShortcuts(applicationPath: string): void { if ( - shortcutCache[applicationPath] === undefined && - !additionalShortcuts.some((shortcut) => shortcut.target === applicationPath) + shortcutCache[applicationPath.toLowerCase()] === undefined && + !additionalShortcuts.some( + (shortcut) => shortcut.target.toLowerCase() === applicationPath.toLowerCase(), + ) ) { additionalShortcuts.push({ target: applicationPath, @@ -184,16 +190,17 @@ function resolveLinks(linkPaths: string[]): ShortcutDetails[] { // Removes all duplicate shortcuts. function removeDuplicates(shortcuts: ShortcutDetails[]): ShortcutDetails[] { const unique = shortcuts.reduce((shortcuts, shortcut) => { - if (shortcuts[shortcut.target]) { + const lowercaseTarget = shortcut.target.toLowerCase(); + if (shortcuts[lowercaseTarget]) { if ( - shortcuts[shortcut.target].args && - shortcuts[shortcut.target].args !== '' && + shortcuts[lowercaseTarget].args && + shortcuts[lowercaseTarget].args !== '' && (!shortcut.args || shortcut.args === '') ) { - shortcuts[shortcut.target] = shortcut; + shortcuts[lowercaseTarget] = shortcut; } } else { - shortcuts[shortcut.target] = shortcut; + shortcuts[lowercaseTarget] = shortcut; } return shortcuts; }, {} as Record<string, ShortcutDetails>); |
