panzerdp / voca

The ultimate JavaScript string library
https://vocajs.pages.dev
MIT License
3.6k stars 137 forks source link

Sanitize logic #64

Open throrin19 opened 11 months ago

throrin19 commented 11 months ago

Expected behavior :smile_cat:

Hello, I want to migrate from String.js older (but very important code) used tu sanitize string in our apps but I can't recreate the same usage with voca.

Actually I use this with string.js :

S(text).trim()
        .latinise()
        .humanize()
        .stripPunctuation()
        .underscore().s

And this is the result I want for this strings :

original sanitized
Volume chaudière & appoint volume_chaudiere_appoint
test_multiunderscore test_multi_underscore
Volume chaudière & appoint 12 volume_chaudiere_appoint_12
A 11yn a_11yn
Well k1 well_k1
test&12 test12
a & b a_b
a&b ab

This is really important to keep this sanitized format for us. Without it, all our application is broken for existing data.

Actual behavior :crying_cat_face:

Actually, I converted this function doing this :

snakeCase(latinise(text))

But I have problem with text with attached numeric and alphanumeric characters, or with special char between them :

original sanitized
A 11yn a_11_yn
Well k1 well_k_1
test&12 test_12
a&b a_b

I test many functions and I can't find any voca function to do our sanitized part

Steps to reproduce :construction_worker:

Pass the original texts into snakeCase(latinise(text))

Technical details: :wrench:

Browser/OS type: directly in node 18 Node version: latest node 18 LTS