Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jeremys/uslug
A permissive slug generator that works with unicode.
https://github.com/jeremys/uslug
Last synced: 11 days ago
JSON representation
A permissive slug generator that works with unicode.
- Host: GitHub
- URL: https://github.com/jeremys/uslug
- Owner: jeremys
- License: mit
- Archived: true
- Created: 2012-02-01T14:37:30.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2021-12-06T11:16:03.000Z (almost 3 years ago)
- Last Synced: 2024-10-30T13:07:58.851Z (14 days ago)
- Language: JavaScript
- Homepage:
- Size: 58.6 KB
- Stars: 81
- Watchers: 3
- Forks: 9
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Uslug.js
Permissive slug generator that works with unicode.
We keep only characters from the categories Letter, Number and Separator (see [Unicode Categories](http://www.unicode.org/versions/Unicode6.0.0/ch04.pdf))
and the common [CJK Unified Ideographs](http://www.unicode.org/versions/Unicode6.0.0/ch12.pdf) as defined in the version 6.0.0 of the Unicode specification.Inspired by [unicode-slugify](https://github.com/mozilla/unicode-slugify).
Note that this slug generator is different from [node-slug](https://github.com/dodo/node-slug) which focus on translating unicode characters to english or latin equivalent.## Quick Examples
uslug('Быстрее и лучше!') // 'быстрее-и-лучше'
uslug('汉语/漢語') // '汉语漢語'uslug('Y U NO', { lower: false })) // 'Y-U-NO'
uslug('Y U NO', { spaces: true })) // 'y u no'
uslug('Y-U|NO', { allowedChars: '|' })) // 'yu|no'## Installation
npm install uslug
## Options
### uslug(string, options)
Generate a slug for the string passed.
__Arguments__
* string - The string you want to slugify.
* options - An optional object that can contain:
* allowedChars: a String of chars that you want to be whitelisted. Default: '-_~'.
* lower: a Boolean to force to lower case the slug. Default: true.
* spaces: a Boolean to allow spaces. Default: false.## License
This project is distributed under the MIT License. See LICENSE file for more information.