RodrigoTomeES / astro-rename

Astro-Rename is an Astro integration that brings postcss-rename functionality to your Astro project without the need for configuration.
https://www.npmjs.com/package/astro-rename
GNU General Public License v3.0
15 stars 4 forks source link

Fix for matchClasses Regular Expression #2

Closed kenchandev closed 10 months ago

kenchandev commented 10 months ago

Thanks for this awesome Astro integration!

When running this Astro integration on a project that uses TailwindCSS classes, I noticed that if I had two CSS classes in the project, for example, h-2 and h-20, then the matchClasses regular expression with the key set to h-2 would match for instances of h-20 (a valid CSS class). This would prevent h-20 from being renamed properly.

The update I made to the regular expression simply adds a negative lookahead assertion that ensures that the match is not followed by any alphanumeric, underscore or hyphen characters (valid characters in a CSS class).

Ideally, if the key is set to h-2, then it should only rename h-2, not h-20, h-2a, h-2_, etc.

RodrigoTomeES commented 10 months ago

Hi @kenchandev thanks for your PR! I will check it this afternoon. I think to mitigate these types of errors I will add tests for the regular expression.

RodrigoTomeES commented 10 months ago

I tested it and you are right. I will release a fix right now. The tests for the regex expression I can't make it now because I have holidays but when I return I will do it.

RodrigoTomeES commented 8 months ago

@all-contributors please add @kenchandev for bug

allcontributors[bot] commented 8 months ago

@RodrigoTomeES

I've put up a pull request to add @kenchandev! :tada: