Skip to content

Commit

Permalink
fix(matchClasses): updated regex to not match for key if immediately …
Browse files Browse the repository at this point in the history
…proceeded by alphanumeric, underscore or hyphen characters
  • Loading branch information
kenchandev authored and RodrigoTomeES committed Aug 11, 2023
1 parent 4056b55 commit 6b37dbe
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ type RenameOptions = {
* The default is to match the name with word boundaries on either side, but you can change this to match only the start or end of the name, or to match more or less than a whole word.
*
* @default ```js
* (key: string) => `(:^|[^-&;:_])(${key})(:$|[^-&;:_\./])`
* (key: string) => `(:^|[^-&;:_])(${key})(?![a-zA-Z0-9_-])(:$|[^-&;:_\./])`
* ```
*/
matchClasses?: (key: string) => string;
Expand Down
2 changes: 1 addition & 1 deletion src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export const defaultOptions = {
by: 'whole',
},
targetExt: ['html', 'js'],
matchClasses: (key: string) => `(:^|[^-&;:_])(${key})(:$|[^-&;:_\./])`,
matchClasses: (key: string) => `(:^|[^-&;:_])(${key})(?![a-zA-Z0-9_-])(:$|[^-&;:_\./])`,
} satisfies RenameOptions;
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export type RenameOptions =
* The default is to match the name with word boundaries on either side, but you can change this to match only the start or end of the name, or to match more or less than a whole word.
*
* @default ```js
* (key: string) => `(:^|[^-&;:_])(${key})(:$|[^-&;:_\./])`
* (key: string) => `(:^|[^-&;:_])(${key})(?![a-zA-Z0-9_-])(:$|[^-&;:_\./])`
* ```
*/
matchClasses?: (key: string) => string;
Expand Down

0 comments on commit 6b37dbe

Please sign in to comment.