Skip to content

feat: add regex-based replace option - #227

Open
RamziSayagh wants to merge 1 commit into
simov:masterfrom
RamziSayagh:feat/replace-option
Open

RamziSayagh wants to merge 1 commit into
simov:masterfrom
RamziSayagh:feat/replace-option

Conversation

@RamziSayagh

Copy link
Copy Markdown

Summary

Adds a replace option to convert regex matches into the configured slug replacement character.

Example

slugify('foo/bar', { replace: /\//g })
// foo-bar

Changes

  • Applies replace before transliteration and default character filtering
  • Preserves existing separator normalization and trimming behavior
  • Adds TypeScript typings, documentation, and tests

@Trott Trott left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds documentation complexity and a maintenance burden for a feature no one has ever asked for or needed and will likely only be used by people confused about what it does. I'm not excited to add a replace option when we already have a sufficiently confusing replacement option. Lastly, if anyone does need this feature, they can simply apply the regex to their input string before sending it to slugify. There's no added benefit to the user (who has to write the regex regardless) in having slugify do this for them.

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

Successfully merging this pull request may close these issues.

2 participants