Skip to content

Commit

Permalink
fix(preset-mini): strict precent handler
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Apr 11, 2023
1 parent f67df15 commit c51d5eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/preset-mini/src/_utils/handlers/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export function number(str: string) {
export function percent(str: string) {
if (str.endsWith('%'))
str = str.slice(0, -1)
if (!numberRE.test(str))
return
const num = parseFloat(str)
if (!Number.isNaN(num))
return `${round(num / 100)}`
Expand Down
3 changes: 3 additions & 0 deletions test/assets/preset-mini-targets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1109,4 +1109,7 @@ export const presetMiniNonTargets = [

// not exists
'text-main/50',

// overmatch
'op50>Foo',
]

0 comments on commit c51d5eb

Please sign in to comment.