simov / simov/slugify

I was about to start working on this feature but I noticed that the issue comes from the default `remove` regex:

Open
#134 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.7k
Forks
142
PR merge metrics
No merged PRs in 30d

Description

I was about to start working on this feature but I noticed that the issue comes from the default remove regex:

/[^\w\s$*_+~.()'"!\-:@]+/g

This regex removes anything that's not in that list, meaning it preserves only the listed characters. The \w flag stands for the a-zA-Z range, meaning anything except those characters will be removed.

So instead we can update the remove regex to remove only the listed characters:

slugify('السلام عليكم ورحمة الله وبركاته', {
  remove: /[$*_+~.()'"!\-:@]+/g
})

And this yields the expected result:

السلام-عليكم-ورحمة-الله-وبركاته

But it didn't work

it return result like this alslam-alykm-wrhmh-allh-wbrkath

I tried to manipulate with the source code and when I remove then Arabic letters from the list charMap it's Works well as expected

Originally posted by @simov in https://github.com/simov/slugify/issues/100#issuecomment-782843177

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the default remove regex and the source charMap, as both are identified as affecting Arabic transliteration. Reproduce the Arabic example from the issue and compare the output with the expected Arabic slug; done means the intended remove option preserves Arabic characters instead of transliterating them.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.