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

It does not work with Persian or Arabic characters #46

Open
Mobasher-NetLinks opened this issue Feb 24, 2019 · 1 comment
Open

It does not work with Persian or Arabic characters #46

Mobasher-NetLinks opened this issue Feb 24, 2019 · 1 comment

Comments

@Mobasher-NetLinks
Copy link

Mobasher-NetLinks commented Feb 24, 2019

Suppose I have a field in collection that may contain Persian characters, now slug does not work with these type of characters, and only add -digits.
What I have used in some where else in my migration script is: str = str.toLowerCase().replace(/([^a-z0-9\-\_\u0621-\u0628\u062A-\u063A\u0641-\u0642\u0644-\u0648\u064E-\u0651\u0655\u067E\u0686\u0698\u06A9\u06AF\u06BE\u06CC]+)/g, slugSeparator).replace(new RegExp(slugSeparator + '{2,}', 'g'), slugSeparator); to support Persian charcters

@Mobasher-NetLinks
Copy link
Author

Mobasher-NetLinks commented Mar 12, 2019

I've used from generator option, and solved. Thanks.

generator: function (slugText, separator) {
  slugText = slugText.toLowerCase().replace(/([^a-z0-9\-\_\u0600-\u06FF]+)/g, separator).replace(new RegExp(separator + '{2,}', 'g'), separator);
  if (slugText.substr(-1) === separator) {
    slugText = slugText.substr(0, slugText.length - 1);
  }
  return slugText;
  }

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