fix: return fallback color for malformed hex instead of NaN#274
Open
codergon wants to merge 1 commit into
Open
fix: return fallback color for malformed hex instead of NaN#274codergon wants to merge 1 commit into
codergon wants to merge 1 commit into
Conversation
|
@codergon is attempting to deploy a commit to the Paper Design Team on Vercel. A member of the Team first needs to authorize it. |
0c80340 to
c71f4a1
Compare
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
getShaderColorFromStringreturnsNaNcolor channels for malformed hex strings instead of falling back to a valid color. ThoseNaNs get uploaded as GPU color uniforms, which produces broken/undefined rendering for the affected shader.The function already has a fallback contract for unparseable input — the existing test asserts
getShaderColorFromString('not-a-color')→[0, 0, 0, 1]. Hex strings just weren't held to it: any hex with invalid characters or an invalid length slipped through toparseInt, yieldingNaN.Changes
[0, 0, 0, 1]) — matching how other unparseable input is already handled — instead of emittingNaN.#rgbashorthand. This is valid CSS that the parser previously mangled intoNaN(it only expanded 3- and 6-digit forms). Expanding it alongside the 3-digit case also keeps the new validation from wrongly rejecting a valid color.Test plan
get-shader-color-from-string.test.ts:#ff0c→[1, 1, 0, 0.8])#gggggg)#12345,#ff)bun testpasses (new cases green, no regressions).bun run buildandtype-checkpass; Prettier clean.