Skip to content

Commit

Permalink
fix: bugs check valid gradient color (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
FajarKim authored Jan 6, 2024
1 parent 04db312 commit b40f9b3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @param {any} hexColor - The input value to check for valid hexadecimal color.
* @returns {boolean} - True if the input is a valid hexadecimal color, false otherwise.
*/
function isValidHexColor(hexColor: any): boolean {
function isValidHexColor(hexColor: string): boolean {
return new RegExp(
/^([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}|[A-Fa-f0-9]{4})$/
).test(hexColor);
Expand All @@ -16,8 +16,8 @@ function isValidHexColor(hexColor: any): boolean {
* @param {string[]} hexColors - The array of hexadecimal colors to check for a valid gradient.
* @returns {boolean} - True if the array represents a valid gradient, false otherwise.
*/
function isValidGradient(hexColors: string[]): boolean {
const colors = [hexColors];
function isValidGradient(hexColors: string): boolean {
const colors = hexColors.split(",");
for (let i = 1; i < colors.length; i++) {
if (!isValidHexColor(colors[i])) {
return false;
Expand Down

0 comments on commit b40f9b3

Please sign in to comment.