diff options
author | Winnie Hellmann <winnie@gitlab.com> | 2019-01-15 09:04:37 +0300 |
---|---|---|
committer | Kushal Pandya <kushalspandya@gmail.com> | 2019-01-15 09:04:37 +0300 |
commit | 159c18221d6759737e689156d473c7e4957e6fd3 (patch) | |
tree | f0a3ef998f7f1126c478344e9bf2cf67db20d75c /app/assets/javascripts/lib/utils/common_utils.js | |
parent | 0e510780a15955b06445fb4c440230151da9ae93 (diff) |
Make parseBoolean idempotent
Diffstat (limited to 'app/assets/javascripts/lib/utils/common_utils.js')
-rw-r--r-- | app/assets/javascripts/lib/utils/common_utils.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/app/assets/javascripts/lib/utils/common_utils.js b/app/assets/javascripts/lib/utils/common_utils.js index 93b347ad09b..3b6a57dad44 100644 --- a/app/assets/javascripts/lib/utils/common_utils.js +++ b/app/assets/javascripts/lib/utils/common_utils.js @@ -430,13 +430,14 @@ export const historyPushState = newUrl => { }; /** - * Returns true for a String "true" and false otherwise. - * This is the opposite of Boolean(...).toString() + * Returns true for a String value of "true" and false otherwise. + * This is the opposite of Boolean(...).toString(). + * `parseBoolean` is idempotent. * * @param {String} value * @returns {Boolean} */ -export const parseBoolean = value => value === 'true'; +export const parseBoolean = value => (value && value.toString()) === 'true'; /** * Converts permission provided as strings to booleans. |