soranoo / next-css-obfuscator

A package deeply inspired by PostCSS-Obfuscator but for Next.js.
https://next-css-obfuscator.vercel.app
MIT License
71 stars 3 forks source link

MultiLine className #4

Closed MrMarmo closed 7 months ago

MrMarmo commented 7 months ago

When having a className, in a .tsx, that spans multiple lines, if the last class name, in any line, doesn't have a space after it, it doesn't get replaced during the obfuscate-build.

fixed it with "regex = new RegExp(`([\\s"'\\\`]|^)(${keyUse})(?=$|[\\s"'\\\`]|\\\\n)`, 'g');" in utils.js

soranoo commented 7 months ago

The obfuscator does not directly work with the files inside the src. It only obfuscates code under the .next folder, which is the NextJS build folder, so it should not be an issue. Version 2.0.0 will be out this weekend and you will get better docs, demos and config. Please wait for it.

soranoo commented 7 months ago

v.2.0.0 has been released.

MrMarmo commented 7 months ago

Sorry. i did mean in the .next folder. see how gap-2 has a "\n" in the compiled js.

Screenshot 2024-01-21 at 2 08 03 PM

2.0 might have fixed this.

soranoo commented 7 months ago

Why there are \n in the compiled JS? This is not supposed to happen. May I have the related part of the source code?

MrMarmo commented 7 months ago

maybe its just a mac thing. idk if it happening on linux. This is just a normal .tsx file compiled with "next build"

Screenshot 2024-01-21 at 2 18 17 PM
{ whoAmI.user_role >= 2 &&
<button className={`text-lg w-full text-left p-2 flex gap-2
hover:bg-gray-100 dark:hover:bg-slate-700
${tab == "bots" && "bg-gray-100 dark:bg-slate-600" }`}
onClick={() => router.push(`/settings/bots`)}
>
    <svg className='flex-shrink-0 w-6 h-6 fill-black dark:fill-white' xmlns="http://www.w3.org/2000/svg" viewBox="-3 0 24 24">
        <path d="m22.3 16.7 1.4-1.4-3.7-3.7-5.8 5.8c-.5-.3-1.1-.4-1.7-.4-1.9 0-3.5 1.6-3.5 3.5s1.6 3.5 3.5 3.5 3.5-1.6 3.5-3.5c0-.6-.2-1.2-.4-1.7l1.9-1.9 2.3 2.3 1.4-1.4-2.3-2.3 1.1-1.1 2.3 2.3zM12.5 22c-.8 0-1.5-.7-1.5-1.5s.7-1.5 1.5-1.5 1.5.7 1.5 1.5-.7 1.5-1.5 1.5z"/>
        <path d="M2 19c0-3.9 3.1-7 7-7 2 0 3.9.9 5.3 2.4l1.5-1.3c-.9-1-1.9-1.8-3.1-2.3C14.1 9.7 15 7.9 15 6c0-3.3-2.7-6-6-6S3 2.7 3 6c0 1.9.9 3.7 2.4 4.8C2.2 12.2 0 15.3 0 19v5h8v-2H2v-3zM5 6c0-2.2 1.8-4 4-4s4 1.8 4 4-1.8 4-4 4-4-1.8-4-4z"/>
    </svg>
        Bots
</button>}
MrMarmo commented 7 months ago

ok, so setting line 151 in utils.js, in 2.0, to this regex = new RegExp(`([\\s"'\\\`]|^)(${keyUse})(?=$|[\\s"'\\\`]|\\\\n)`, 'g'); fixes it still. but idk if i will break any thing else. prob not.

without change:

Screenshot 2024-01-21 at 2 30 16 PM

with change:

Screenshot 2024-01-21 at 2 31 23 PM
soranoo commented 7 months ago

Thank you for your contribution.

I just updated the npm package. Check out the v.2.0.1