Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid replacing . with - by lodash.kebabcase #3

Open
gaetansenn opened this issue Jan 23, 2019 · 0 comments
Open

Avoid replacing . with - by lodash.kebabcase #3

gaetansenn opened this issue Jan 23, 2019 · 0 comments

Comments

@gaetansenn
Copy link

The method kebabcase from lodash replace the char . with -

We can replace the kebabcase method with this :

removeNonAsciiChar(
    transform(
      text.toString()
    )
  ).toLowerCase()
    .replace(/\s+/g, '-')         // Replace spaces with -
    .replace(/&/g, '-and-')       // Replace & with 'and'
    .replace(/[^\w\-\.]+/g, '')   // Remove all non-word chars
    .replace(/\--+/g, '-')        // Replace multiple - with single -
    .replace(/^-+/, '')           // Trim - from start of text
    .replace(/-+$/, '')           // Trim - from end of text

What do you think ?

@atinux @benjamincanac

@gaetansenn gaetansenn changed the title Avoid replacing . with - by lodash.kebabcase Avoid replacing . with - by lodash.kebabcase Jan 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant