Skip to content

Commit db6d0e1

Browse files
committed
fix: correct regex to only match rgba/hsla alpha channels
1 parent 0a83e40 commit db6d0e1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/tailwindcss/src/utils/replace-shadow-colors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function extractAlpha(color: string): string | null {
2626
}
2727

2828
// Legacy rgba/hsla syntax with comma: rgba(0, 0, 0, 0.12)
29-
const commaAlphaMatch = color.match(/,\s*([\d.]+)\s*\)/)
29+
// Must be rgba/hsla (with 'a') to have 4 values where the last is alpha`n const commaAlphaMatch = color.match(/^(?:rgba|hsla)\([^,]+,[^,]+,[^,]+,\s*([\d.]+)\s*\)$/i)
3030
if (commaAlphaMatch) {
3131
const alpha = commaAlphaMatch[1]
3232
const alphaNum = parseFloat(alpha)

0 commit comments

Comments
 (0)