Skip to content

Commit

Permalink
fix(plugin-compiler): css 压缩校验类名时重置正则 lastIndex,解决部分场景匹配异常问题
Browse files Browse the repository at this point in the history
  • Loading branch information
hwaphon committed Apr 16, 2024
1 parent 7c9153c commit 094ad4c
Showing 1 changed file with 1 addition and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ export class CSSClassNameCompressPlugin implements Plugin {
const result = []
const splitBySpace = (param) => param.split(/(?<=\S)\s/gi)

regex.lastIndex = 0 // 重置 lastIndex, 否则某些场景会导致匹配值异常
// 循环匹配正则表达式
while ((match = regex.exec(input)) !== null) {
// 如果匹配到的不是空格,且不是字符串的开始位置,则将之前的字符串加入结果数组
Expand Down

0 comments on commit 094ad4c

Please sign in to comment.