Skip to content

Commit

Permalink
fix: improve boolean parse behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
rickstaa committed Sep 17, 2022
1 parent c1324b3 commit 82554b0
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,22 @@ function isValidHexColor(hexColor) {
}

/**
* @param {string} value
* @returns {boolean | string}
* @param {string | boolean} value
* @returns {boolean | undefined }
*/
function parseBoolean(value) {
if (value === "true") {
return true;
} else if (value === "false") {
return false;
if (typeof value === 'boolean'){
return value
} else if (typeof value === 'string') {
if (value.toLowerCase() === "true") {
return true;
} else if (value.toLowerCase() === "false") {
return false;
} else {
return undefined;
}
} else {
return value;
return undefined;
}
}

Expand Down

0 comments on commit 82554b0

Please sign in to comment.