Skip to content

fix(isRgbColor): keep numeric values contiguous when allowing spaces - #2886

Open
emme1t wants to merge 1 commit into
validatorjs:masterfrom
emme1t:fix/rgb-contiguous-values
Open

fix(isRgbColor): keep numeric values contiguous when allowing spaces#2886
emme1t wants to merge 1 commit into
validatorjs:masterfrom
emme1t:fix/rgb-contiguous-values

Conversation

@emme1t

@emme1t emme1t commented Sep 12, 2026

Copy link
Copy Markdown

Fixes #2885.

With allowSpaces: true, values such as rgb(2 55,0,0) and rgba(0,0,0,0. 5) currently pass because whitespace removal joins separate parts of a number. Check for whitespace inside numeric and percentage tokens before the existing normalization step.

Regression coverage includes integer channels, percentage channels, decimal alpha values, spaces, tabs, and newlines. Whitespace around complete values remains accepted, and both includePercentValues settings are covered.

Validation on Windows with Node.js 24.16.0:

  • New regression test on the original source: failed on rgb(2 55,0,0).
  • New regression test with the fix: passed.
  • npm test: builds and ESLint passed; 324 tests passed.
  • Checked the same examples against both the source and generated Node modules.
  • Independently checked the 3 valid and 8 invalid examples with Chromium 151's CSS.supports('color', value); all results match the regression expectations.
  • git diff --check: passed.

Checklist

  • Changes are limited to the reported behavior and its regression tests.
  • Existing API options and defaults are preserved.
  • Tests cover the changed behavior.

AI assistance: OpenAI Codex prepared the change, ran the local checks, and performed a separate review of the patch.

@codecov

codecov Bot commented Sep 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (9ff3424) to head (3eee6e7).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2886   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       114           
  Lines         2599      2600    +1     
  Branches       658       658           
=========================================
+ Hits          2599      2600    +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

isRgbColor accepts whitespace inside numeric values with allowSpaces: true

1 participant