From 97d9cecbef9d09d536c8879a5f1bac8240dfbc3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luka=20Mom=C4=8Dilovi=C4=87?= Date: Wed, 25 Sep 2024 20:31:39 +0200 Subject: [PATCH] fix: check for exact match instead of partial Split the check boxes into array and in the if statement check for exact match to avoid collisions like obs being selected when only obsidian is provided due to partial match fix: #2819 --- functions/public/Invoke-WPFPresets.ps1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/functions/public/Invoke-WPFPresets.ps1 b/functions/public/Invoke-WPFPresets.ps1 index 90493899c7..0e25f717ee 100644 --- a/functions/public/Invoke-WPFPresets.ps1 +++ b/functions/public/Invoke-WPFPresets.ps1 @@ -42,6 +42,9 @@ function Invoke-WPFPresets { Write-Debug "$debugMsg" } + # Split the checkboxes to check into an array + $CheckBoxesToCheckArray = $CheckBoxesToCheck.Split(" ") + foreach ($CheckBox in $CheckBoxes) { $checkboxName = $CheckBox.Key @@ -50,8 +53,8 @@ function Invoke-WPFPresets { continue } - # Check if the checkbox name exists in the flattened JSON hashtable - if ($CheckBoxesToCheck.Contains($checkboxName)) { + # Check if the checkbox name exists in the array as exact match + if ($CheckBoxesToCheckArray -contains $CheckBoxName) { # If it exists, set IsChecked to true $sync.$checkboxName.IsChecked = $true Write-Debug "$checkboxName is checked"