Skip to content

Commit

Permalink
Fixes #57, additional catch for any other category number
Browse files Browse the repository at this point in the history
  • Loading branch information
ddxv committed Sep 19, 2024
1 parent 5249a08 commit 8488012
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,18 @@
$: console.log('homeCategorySelection:', $homeCategorySelection);
// TODO: This categorySelection is shared with the numerical one used on other pages!
function isNumeric(value: string | number): boolean {
// If the value is a number, check if it's finite.
if (typeof value === 'number') {
return isFinite(value);
}
// If the value is a string, try parsing it as a float.
return !isNaN(parseFloat(value)) && isFinite(parseFloat(value));
}
// Set categorySelection based on whether the value is numeric or null
$: categorySelection =
$homeCategorySelection === '1' || $homeCategorySelection === null
isNumeric($homeCategorySelection) || $homeCategorySelection === null
? 'overall'
: $homeCategorySelection;
Expand Down

0 comments on commit 8488012

Please sign in to comment.