@bustle/slugify
Advanced tools
Comparing version 1.2.1 to 2.0.0
36
index.js
@@ -1,12 +0,28 @@ | ||
const slug = require('./slug') | ||
const slugify = require('slugify') | ||
const STOP_WORDS = ['and', 'or', 'an'] | ||
const IGNORE_CHARS = ['$'] | ||
const STOP_WORDS = new Set(['and', 'or', 'an']) | ||
IGNORE_CHARS.forEach(char => { slug.charmap[char] = '' }) | ||
slugify.extend({ | ||
$: '', | ||
'&': '', | ||
'|': '', | ||
'☠': 'skull-bones', | ||
'☣': 'biohazard', | ||
'☭': 'hammer-sickle', | ||
'☯': 'yin-yang', | ||
'☮': 'peace', | ||
'☏': 'telephone', | ||
'☎': 'telephone', | ||
'★': 'star', | ||
'☂': 'umbrella', | ||
'☃': 'snowman', | ||
'✈': 'airplane', | ||
'✉': 'envelope', | ||
'✊': 'raised-fist' | ||
}) | ||
function slugify (input) { | ||
return slug(input, { lower: true }) | ||
function slug (input) { | ||
return slugify(String(input), { replacement: '-', lower: true, remove: /[^\w\s_~-]+/g }) | ||
.split('-') | ||
.filter(word => word && (STOP_WORDS.indexOf(word) === -1)) | ||
.filter(word => word && !STOP_WORDS.has(word)) | ||
.join('-') | ||
@@ -17,3 +33,3 @@ } | ||
if (!string) { return `${id}` } | ||
return `${slugify(string)}-${id}` | ||
return `${slug(string)}-${id}` | ||
} | ||
@@ -23,7 +39,7 @@ | ||
if (!string) { return `${id}` } | ||
return `${id}-${slugify(string)}` | ||
return `${id}-${slug(string)}` | ||
} | ||
module.exports = { | ||
slug: slugify, | ||
slug, | ||
slugUser: user => makeSlug(user.id, user.name), | ||
@@ -30,0 +46,0 @@ slugPost: post => makeSlug(post.id, post.title), |
{ | ||
"name": "@bustle/slugify", | ||
"version": "1.2.1", | ||
"version": "2.0.0", | ||
"description": "Slug all our things into slugs", | ||
@@ -10,7 +10,7 @@ "main": "index.js", | ||
"engines": { | ||
"node": ">=4.3" | ||
"node": ">=12" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/bustlelabs/slugify.git" | ||
"url": "git+https://github.com/bustle/slugify.git" | ||
}, | ||
@@ -23,10 +23,13 @@ "keywords": [ | ||
"bugs": { | ||
"url": "https://github.com/bustlelabs/slugify/issues" | ||
"url": "https://github.com/bustle/slugify/issues" | ||
}, | ||
"homepage": "https://github.com/bustlelabs/slugify#readme", | ||
"homepage": "https://github.com/bustle/slugify#readme", | ||
"devDependencies": { | ||
"mocha": "^3.2.0", | ||
"should": "^11.2.1", | ||
"standard": "^9.0.0" | ||
"mocha": "^8.1.3", | ||
"should": "^13.2.3", | ||
"standard": "^14.3.4" | ||
}, | ||
"dependencies": { | ||
"slugify": "^1.4.5" | ||
} | ||
} |
# bustle slugify | ||
[![Build Status](https://travis-ci.com/bustlelabs/slugify.svg?token=1KJeREEe58xVHvYm9rGo&branch=master)](https://travis-ci.com/bustlelabs/slugify) | ||
[![Build Status](https://api.travis-ci.org/bustle/slugify.svg?branch=master)](https://travis-ci.org/github/bustle/slugify) | ||
@@ -14,3 +14,3 @@ This is how you slug our things. | ||
This module copies in the `slug` module from npm and the single unicode table it uses for symbol lookups. Installs much faster and doesn't use external services. | ||
This module just uses the `slugify` module from npm and adds some minor bustle-specific adjustments. | ||
@@ -28,4 +28,2 @@ # Api | ||
## slugUser(user:{id!, name}) -> slug | ||
Users have the id last, don't use this until [nighthawk](https://github.com/bustlelabs/nighthawk/issues/331) can deal with it. | ||
```js | ||
@@ -32,0 +30,0 @@ assert.equal(slugUser({ id: 1, name: 'Penny Dog' }), 'penny-dog-1') |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
3212
1
3
40
47
+ Addedslugify@^1.4.5
+ Addedslugify@1.6.6(transitive)