Gathering detailed insights and metrics for slugify
Gathering detailed insights and metrics for slugify
Gathering detailed insights and metrics for slugify
Gathering detailed insights and metrics for slugify
npm install slugify
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
1,529 Stars
211 Commits
131 Forks
8 Watching
1 Branches
39 Contributors
Updated on 28 Nov 2024
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
6.6%
901,722
Compared to previous day
Last week
4.4%
4,582,070
Compared to previous week
Last month
11.1%
18,841,416
Compared to previous month
Last year
37%
168,017,272
Compared to previous year
4
1var slugify = require('slugify') 2 3slugify('some string') // some-string 4 5// if you prefer something other than '-' as separator 6slugify('some string', '_') // some_string
1slugify('some string', { 2 replacement: '-', // replace spaces with replacement character, defaults to `-` 3 remove: undefined, // remove characters that match regex, defaults to `undefined` 4 lower: false, // convert to lower case, defaults to `false` 5 strict: false, // strip special characters except replacement, defaults to `false` 6 locale: 'vi', // language code of the locale to use 7 trim: true // trim leading and trailing replacement chars, defaults to `true` 8})
For example, to remove *+~.()'"!:@
from the result slug, you can use slugify('..', {remove: /[*+~.()'"!:@]/g})
.
remove
is a regular expression, it should be a
character class
and only a character class. It should also use the
global flag.
(For example: /[*+~.()'"!:@]/g
.) Otherwise, the remove
option might not
work as expected.remove
is a string, it should be a single character.
Otherwise, the remove
option might not work as expected.The main charmap.json
file contains all known characters and their transliteration. All new characters should be added there first. In case you stumble upon a character already set in charmap.json
, but not transliterated correctly according to your language, then you have to add those characters in locales.json
to override the already existing transliteration in charmap.json
, but for your locale only.
You can get the correct language code of your language from here.
Out of the box slugify
comes with support for a handful of Unicode symbols. For example the ☢
(radioactive) symbol is not defined in the charMap
and therefore it will be stripped by default:
1slugify('unicode ♥ is ☢') // unicode-love-is
However you can extend the supported symbols, or override the existing ones with your own:
1slugify.extend({'☢': 'radioactive'}) 2slugify('unicode ♥ is ☢') // unicode-love-is-radioactive
Keep in mind that the extend
method extends/overrides the default charMap
for the entire process. In case you need a fresh instance of the slugify's charMap
object you have to clean up the module cache first:
1delete require.cache[require.resolve('slugify')] 2var slugify = require('slugify')
charmap.json
npm test
index.js
and will sort the charmap.json
Originally this was a vanilla javascript port of node-slug.
Note that the original slug module has been ported to vanilla javascript too.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
Found 12/22 approved changesets -- score normalized to 5
Reason
1 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More