Skip to content

Avoid replacing . with - by lodash.kebabcase #3

@gaetansenn

Description

@gaetansenn

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions