Skip to content

Commit

Permalink
fix: update capture regex
Browse files Browse the repository at this point in the history
  • Loading branch information
zyyv committed Apr 25, 2024
1 parent 5642761 commit d6a09d5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/preset-legacy-compat/src/comma-color.ts
@@ -1,5 +1,5 @@
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'
Expand Down
2 changes: 1 addition & 1 deletion test/preset-legacy-compat.test.ts
Expand Up @@ -25,7 +25,7 @@ describe('preset-legacy-compat', () => {

await expect(css).toMatchInlineSnapshot(`
"/* layer: default */
.bg-\\[rgba\\(255\\,255\\,255\\,0\\.1\\)\\]{--un-bg-opacity:0.1;background-color:rgb(255, 255, 255, var(--un-bg-opacity));}
.bg-\\[rgba\\(255\\,255\\,255\\,0\\.1\\)\\]{--un-bg-opacity:0.1;background-color:rgba(255, 255, 255, var(--un-bg-opacity));}
.text-red{--un-text-opacity:1;color:rgba(248, 113, 113, var(--un-text-opacity));}"
`)
})
Expand Down

0 comments on commit d6a09d5

Please sign in to comment.