Open Mobasher-NetLinks opened 5 years ago
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;
}
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