Skip to content

isRgbColor does not ignore spaces between params #2028

@a-h-i

Description

@a-h-i

Describe the bug
A clear and concise description of what the bug is.

unlike other color testing, such as isHSL isRgb does not ignore spaces

Examples
Sample stackblitz

import validator from 'validator';
const testString = 'rgb(204, 0, 102)';
console.log('isRGB with spaces', validator.isRgbColor(testString));
console.log(
  'isRGB no spaces',
  validator.isRgbColor(testString.replace(/\s/g, ''))
);
console.log('isHSL', validator.isHSL('hsl(300, 100%, 40%)'));

Expected output

isRGB with spaces true
isRGB no spaces true
isHSL true

Actual output

isRGB with spaces false
isRGB no spaces true
isHSL true

Additional context
Validator.js version: 13.7
Node.js version: 18
OS platform: [windows, linux, macOS, etc] linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions