Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): Fix incorrect default value setting OR operator when parsing React configs #103

Merged

Conversation

deadlycoconuts
Copy link
Contributor

Context

The OR operator used to set default values for REACT_APP_ALLOW_CUSTOM_STREAM and REACT_APP_ALLOW_CUSTOM_TEAM is incorrect.

Example:
What we want is when REACT_APP_ALLOW_CUSTOM_STREAM is defined, return the value of REACT_APP_ALLOW_CUSTOM_STREAM, otherwise return true. However, when REACT_APP_ALLOW_CUSTOM_STREAM is false:

getEnv("REACT_APP_ALLOW_CUSTOM_STREAM") || true 
is equals to false || true 
is equals to true

which is incorrect.

This PR fixes this by replacing the OR operator with a ternary operator to check if the environment variable is defined or not, and returns that value if it is, and returns true if it isn't:

getEnv("REACT_APP_ALLOW_CUSTOM_STREAM") != null
      ? getEnv("REACT_APP_ALLOW_CUSTOM_STREAM")
      : true

@deadlycoconuts deadlycoconuts added the bug Something isn't working label Jun 4, 2024
@deadlycoconuts deadlycoconuts self-assigned this Jun 4, 2024
@deadlycoconuts deadlycoconuts merged commit 0256c00 into caraml-dev:main Jun 5, 2024
8 checks passed
@deadlycoconuts deadlycoconuts deleted the fix_js_env_var_parsing_bug branch June 28, 2024 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants