Skip to content

Commit

Permalink
fix: check for exact match instead of partial
Browse files Browse the repository at this point in the history
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: ChrisTitusTech#2819
  • Loading branch information
momcilovicluka committed Sep 25, 2024
1 parent 662139c commit 97d9cec
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions functions/public/Invoke-WPFPresets.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"
Expand Down

0 comments on commit 97d9cec

Please sign in to comment.