Skip to content

Commit

Permalink
use regex
Browse files Browse the repository at this point in the history
  • Loading branch information
sai6855 committed Feb 29, 2024
1 parent 78b8474 commit a17eea0
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,17 @@ export default function transformer(file, api, options) {
});
});

const selector = `${replacementSelectorPrefix}${deprecatedClass}`;
const selectorRegex = new RegExp(`${replacementSelectorPrefix}${deprecatedClass}(.|$)`);
root
.find(j.Literal, (literal) => typeof literal.value === 'string' && literal.value === selector)
.find(
j.Literal,
(literal) => typeof literal.value === 'string' && literal.value.match(selectorRegex),
)
.forEach((path) => {
path.replace(
j.literal(
path.value.value.replace(
selector,
selectorRegex,
`${replacementSelectorPrefix}${replacementSelector}`,
),
),
Expand Down

0 comments on commit a17eea0

Please sign in to comment.