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: handle hex colors without a preceeding # and refactor #916

Merged

Conversation

lbrooks
Copy link
Contributor

@lbrooks lbrooks commented Oct 21, 2024

Two edge cases for this two functions would result in NaN being contained within the returned color matrix:

Supplying a hex color string without a preceeding #
Supplying a string that was not in the hex or rgb color format.

This PR covers those two cases by:

  • Supporting hex colors without a preceeding #
  • Defaults to black if the input string is neither a hex or rgb color

Additionally this PR also

  • Eliminates the double call to parseInt when supplying a hex color
  • Added test coverage
  • Refactored out the common used method to de-duplicate

@lbrooks lbrooks marked this pull request as ready for review October 21, 2024 00:47
* function would return NaN in the matrix if supplied with a hex color
  without a preceeding #
* eliminated double calls to parseInt when supplying a hex color
* added handling for the case where supplied string is neither a hex nor
  rgb color (defaulting to black)
* added tests

Signed-off-by: Lawrence Brooks <[email protected]>
@lbrooks lbrooks force-pushed the color-matrix-calculation-test branch from 050a4fb to f5ffa06 Compare October 23, 2024 21:15
@alexpargon alexpargon merged commit 0517d86 into Dygmalab:development Oct 29, 2024
5 of 8 checks passed
@lbrooks lbrooks deleted the color-matrix-calculation-test branch October 29, 2024 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants