Commit f8565c1
To modify the "1" matched in the regular expression to match all integers and decimals in Infinite issue
The original regex is designed to match patterns like calc(infinity * 1px) or calc(infinity * 1rpx).
When using a custom design width (e.g., 390 design units), Taro automatically calculates the ratio relative to the standard mini-program design width of 750. This results in formats like calc(infinite * 1.91rpx). However, the original regular expression can only handle scenarios with the 750 design width, causing the rounded-full replacement to fail.
It is now proposed to modify the regex to match all numeric cases, thereby expanding the range of applicable scenarios.
* (\d+\.?\d*|\.\d+) is used to match integers or decimals:
* \d+\.?\d* : Matches integers with one or more digits, which can be followed by a decimal point and zero or more decimal digits (e.g., 1, 1., 1.2).
* |\.\d+ : Alternatively, matches pure decimals starting with a decimal point (e.g., .5).
This regular expression can match the following formats:
* calc(infinity * 5px)
* calc(infinity * 3.14rpx)
* calc(infinity * .6px)
* calc(infinity * 100.px)1 parent 0316c6d commit f8565c1
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
0 commit comments