瀏覽代碼

fix: match possible whitespace chars at the start

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
tags/v1.3.1
Chinmay D. Pai 5 年之前
父節點
當前提交
2eb61e46c0
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: 75507BE256F40CED
共有 1 個檔案被更改,包括 2 行新增2 行删除
  1. +2
    -2
      src/js/utils/colors.js

+ 2
- 2
src/js/utils/colors.js 查看文件

@@ -37,8 +37,8 @@ export function lightenDarkenColor(color, amt) {

export function isValidColor(string) {
// https://stackoverflow.com/a/32685393
let HEX_RE = /^(#)((?:[A-Fa-f0-9]{3}){1,2})$/i
let RGB_RE = /^(rgb|hsl)(a?)[(]\s*([\d.]+\s*%?)\s*,\s*([\d.]+\s*%?)\s*,\s*([\d.]+\s*%?)\s*(?:,\s*([\d.]+)\s*)?[)]$/i
let HEX_RE = /(^\s*)(#)((?:[A-Fa-f0-9]{3}){1,2})$/i
let RGB_RE = /(^\s*)(rgb|hsl)(a?)[(]\s*([\d.]+\s*%?)\s*,\s*([\d.]+\s*%?)\s*,\s*([\d.]+\s*%?)\s*(?:,\s*([\d.]+)\s*)?[)]$/i
return HEX_RE.test(string) || RGB_RE.test(string);
}



Loading…
取消
儲存