Skip to content

Commit

Permalink
fix(id-class-value): fix inefficient regex
Browse files Browse the repository at this point in the history
The positive lookahead assertion `(?= ...)` is used to ensure that the check occurs after the first
lowercase letter and all subsequent characters have been verified to resolve the issue of reference
backtracking

htmlhint#1147
  • Loading branch information
bebehr committed Feb 20, 2024
1 parent 5163d31 commit ea7ea2d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/rules/id-class-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default {
'The id and class attribute values must be in lowercase and split by a dash.',
},
hump: {
regId: /^[a-z][a-zA-Z\d]*(?:[A-Z][a-zA-Z\d]*)*$/,
regId: /^[a-z](?=[a-zA-Z\d]*$)(?:[a-zA-Z\d]*(?:[A-Z][a-zA-Z\d]*)*)?$/,
message:
'The id and class attribute values must meet the camelCase style.',
},
Expand Down

0 comments on commit ea7ea2d

Please sign in to comment.