From f8723810b67600c7bc317d26744fd845d13468c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20K=C3=BChnapfel?= Date: Fri, 3 Feb 2023 10:07:32 +0100 Subject: [PATCH] fix ColorConvert does not accept uppercase hex values --- CHANGELOG.md | 4 ++++ README.md | 2 +- package.json | 2 +- src/index.ts | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71d4338..6caa7f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 9e0d6b3..2610afd 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/package.json b/package.json index b5aeeb1..21d10b0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@interaktiv.de/colors", - "version": "1.2.1", + "version": "1.2.2", "description": "Color converter for JavaScript/TypeScript", "keywords": [ "color", diff --git a/src/index.ts b/src/index.ts index 55a78e5..dd23d99 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 = { black: [0, 0, 0, 1],