Skip to content

Commit

Permalink
fix ColorConvert does not accept uppercase hex values
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Kühnapfel committed Feb 3, 2023
1 parent bedc83b commit f872381
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.2.2] - 2023-02-03
## Fixed
- Made `ColorConvert` accept hex values in upper case

## [1.2.1] - 2022-08-23
### Added
- `LICENSE` file
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Interaktiv Colors

[![code style: ts-standard](https://img.shields.io/badge/code%20style-ts--standard-blue)](https://standardjs.com/)
![Version: 1.2.0](https://img.shields.io/badge/version-1.2.0-242424)
![Version: 1.2.2](https://img.shields.io/badge/version-1.2.2-242424)

Color converter for JavaScript/TypeScript.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@interaktiv.de/colors",
"version": "1.2.1",
"version": "1.2.2",
"description": "Color converter for JavaScript/TypeScript",
"keywords": [
"color",
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { CssColorNames, RegExResult, RgbaValues } from './types'

export default class ColorConvert {
static #RGB_STRING_REGEX = /^rgb\( *(\d{1,2}|1\d{2}|2[0-4]\d|25[0-5]) +(\d{1,2}|1\d{2}|2[0-4]\d|25[0-5]) +(\d{1,2}|1\d{2}|2[0-4]\d|25[0-5]) *(\/ *(?:\d{1,2}|100)%)?\)|rgb\( *(\d{1,2}|1\d{2}|2[0-4]\d|25[0-5]) *, *(\d{1,2}|1\d{2}|2[0-4]\d|25[0-5]) *, *(\d{1,2}|1\d{2}|2[0-4]\d|25[0-5]) *\)|rgba\( *(\d{1,2}|1\d{2}|2[0-4]\d25[0-5]) *, *(\d{1,2}|1\d{2}|2[0-4]\d25[0-5]) *, *(\d{1,2}|1\d{2}|2[0-4]\d25[0-5]) *, *(0?\.\d+|1(?:\.0+)?) *\)$/
static #HEX_STRING_REGEX = /^#(?:([\da-f])([\da-f])([\da-f])([\da-f])?|([\da-f]{2})([\da-f]{2})([\da-f]{2})([\da-f]{2})?)$/
static #HEX_STRING_REGEX = /^#(?:([\da-f])([\da-f])([\da-f])([\da-f])?|([\da-f]{2})([\da-f]{2})([\da-f]{2})([\da-f]{2})?)$/i
static #HSL_STRING_REGEX = /^hsl\( *(-?(?:\d+(?:\.\d+)?|0?\.\d+)(?:deg|g?rad|turn)?) *, *(\d{1,2}(?:\.\d+)?|100)% *, *(\d{1,2}(?:\.\d+)?|100)%*\)|hsla\( *(-?(?:\d+(?:\.\d+)?|0?\.\d+)(?:deg|g?rad|turn)?) *, *(\d{1,2}(?:\.\d+)?|100)% *, *(\d{1,2}(?:\.\d+)?|100)% *, *(0?\.\d+|1(?:\.0+)) *\)|hsl\( *(-?(?:\d+(?:\.\d+)?|0?\.\d+)(?:deg|g?rad|turn)?) +(\d{1,2}(?:\.\d+)?|100)% +(\d{1,2}(?:\.\d+)?|100)%(?: *| *\/ *((?:\d{1,2}(?:\.\d+)?|100)%|1(?:\.0+)?|0?\.\d+) *)\)$/
static #CSS_COLORS: Record<CssColorNames, RgbaValues> = {
black: [0, 0, 0, 1],
Expand Down

0 comments on commit f872381

Please sign in to comment.