Skip to content

Commit

Permalink
fix(preset-legacy-compat): update the split color string regex (#3756)
Browse files Browse the repository at this point in the history
  • Loading branch information
zyyv committed Apr 25, 2024
1 parent 3827444 commit 47eafba
Show file tree
Hide file tree
Showing 5 changed files with 206 additions and 153 deletions.
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -3,7 +3,7 @@
"type": "module",
"version": "0.59.4",
"private": true,
"packageManager": "pnpm@9.0.2",
"packageManager": "pnpm@9.0.6",
"scripts": {
"postinstall": "esno scripts/prepare.ts",
"taze": "taze minor -wIr && pnpm -r --parallel run update-post",
Expand Down Expand Up @@ -66,6 +66,7 @@
"@unocss/postcss": "workspace:*",
"@unocss/preset-attributify": "workspace:*",
"@unocss/preset-icons": "workspace:*",
"@unocss/preset-legacy-compat": "workspace:*",
"@unocss/preset-mini": "workspace:*",
"@unocss/preset-tagify": "workspace:*",
"@unocss/preset-typography": "workspace:*",
Expand Down
4 changes: 2 additions & 2 deletions packages/preset-legacy-compat/src/comma-color.ts
@@ -1,10 +1,10 @@
export function toCommaStyleColorFunction(str: string) {
return str.replace(/(rgb|hsl)a?\(([^)]+)\)/g, (_, fn: string, v: string) => {
return str.replace(/((?:rgb|hsl)a?)\(([^)]+)\)/g, (_, fn: string, v: string) => {
const [rgb, alpha] = v.split(/\//g).map(i => i.trim())
if (alpha && !fn.endsWith('a'))
fn += 'a'

const parts = rgb.split(/(?!,)\s+/).map(i => i.trim())
const parts = rgb.split(/,?\s+/).map(i => i.trim())
if (alpha)
parts.push(alpha)

Expand Down

0 comments on commit 47eafba

Please sign in to comment.