dodo / node-slug

slugifies even utf-8 chars!
MIT License
1.08k stars 92 forks source link

Failed to slug Arabic/RTL text #60

Open montaro opened 8 years ago

montaro commented 8 years ago
  const text = 'لماذا نعيش؟';
  const print = console.log.bind(console, '>');
  print('text to slug: ', text);  // > لماذا نعيش؟
  print('text slugged: ', slug(text));  // > undefined
  print('text really slugged: ', slug(text, {lowercase: false}));    // > undefined
dmaii commented 8 years ago

This library won't parse those characters because they'er not a part of the So category of unicode characters. This library only parses characters from that category.

I ran into the same issue so I ended up creating my own fork, which handles your use case, since I wasn't sure what the author's intent was.

montaro commented 8 years ago

Thanks @suisha for your reply. Actually I in my case I did not like to have transliteration in URLs, so I overrided the slug generator function using this lib https://www.npmjs.com/package/arslugify and it worked for me with https://www.npmjs.com/package/mongoose-url-slugs

Thanks again!