New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

larvitslugify

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

larvitslugify - npm Package Compare versions

Comparing version 0.10.10 to 0.11.0

.eslintrc

26

package.json
{
"name": "larvitslugify",
"description": "Slugifies even utf-8 chars!",
"version": "0.10.10",
"description": "Slugify string to make them url safe and more",
"version": "0.11.0",
"homepage": "https://github.com/larvit/larvitslugify",
"author": "Lilleman <lilleman@larvit.se>",
"contributors": [
{
"name": "pdehaan (https://github.com/pdehaan"
}
],
"repository": {

@@ -19,3 +14,3 @@ "type": "git",

},
"main": "slug.js",
"main": "index.js",
"keywords": [

@@ -25,5 +20,2 @@ "slugify",

"string",
"utf8",
"utf-8",
"unicode",
"url"

@@ -34,13 +26,7 @@ ],

},
"dependencies": {
"unicode": "^0.6.1"
},
"devDependencies": {
"mocha": "^2.4.5",
"should": "^8.3.0"
"mocha": "^3.2.0",
"mocha-eslint": "^3.0.1"
},
"bin": {
"slug": "bin/slug.js"
},
"license": "MIT"
"license": "ISC"
}

@@ -5,14 +5,5 @@ [![Build Status](https://travis-ci.org/larvit/larvitslugify.svg?branch=master)](https://travis-ci.org/larvit/larvitslugify) [![Dependencies](https://david-dm.org/larvit/larvitslugify.svg)](https://david-dm.org/larvit/larvitslugify.svg)

Forked from [slug](https://github.com/dodo/node-slug) and added some pull requests and options.
Slugifies every string, even when it contains unicode!
Make strings url-safe.
- respecting [RFC 3986](https://tools.ietf.org/html/rfc3986)
- Comprehensive tests
- No dependencies (except the unicode table)
- Not in coffee-script (except the tests lol)
- Coerces foreign symbols to their english equivalent
- Works in browser (window.slug) and AMD/CommonJS-flavoured module loaders (except the unicode symbols unless you use browserify but who wants to download a ~2mb js file, right?)
Why not use slug? Or slugify? Well, I built this because I wanted a more transparent and powerfull implementation. If I wanted to preserve "/" and change "." to ":" I want to be able to do that, but still have the comfort of everything else being a default slugifier.

@@ -26,23 +17,15 @@ ```

```javascript
var slug = require('larvitslugify'),
print = console.log.bind(console, '>')
const slug = require('larvitslugify');
print(slug('i ♥ unicode'))
// > i-love-unicode
slug('i ♥ unicode'); // > i-love-unicode
slug('unicode ♥ is ☢'); // > unicode-love-is-radioactive
print(slug('unicode ♥ is ☢')) // yes!
// > unicode-love-is-radioactive
// If you prefer something else then `-` as seperator
slug('i ♥ unicode', '_'); // > i_love_unicode
print(slug('i ♥ unicode', '_')) // If you prefer something else then `-` as seperator
// > i_love_unicode
// Change default charmap or use option {charmap:{…}} as 2. argument
slug.charmap['♥'] = 'freaking love'
slug('I ♥ UNICODE')); // > I-freaking-love-UNICODE
slug.charmap['♥'] = 'freaking love' // change default charmap or use option {charmap:{…}} as 2. argument
print(slug('I ♥ UNICODE'))
// > I-freaking-love-UNICODE
print(slug('☏-Number', {lower: true})) // If you prefer lower case
// > telephone-number
print(slug('i <3 unicode'))
// > i-love-unicode
slug('i <3 unicode'); // > i-love-unicode
```

@@ -53,4 +36,4 @@

```javascript
// Options is either object or replacement (sets options.replacement)
slug('string', [{options} || 'replacement']);
// Options is either object or whitespaceReplaceChar (sets options.whitespaceReplaceChar)
slug('string', [{options} || 'whitespaceReplaceChar']);
```

@@ -62,49 +45,12 @@

slug('string', {
'replacement': '-', // Replace spaces with replacement
'symbols': true, // Replace unicode symbols or not
'remove': /[d]/g, // Regex to remove characters
'lower': true, // Result in lower case
'charmap': {'Ä': 'ae'}, // Replace special characters
'multicharmap': {'ð': 'oi'}, // Replace multi-characters
'save': ['*', 'ð'], // Do not replace these characters, also takes a string
'wordLimit': 5 // Limits the amount of words to this number
'whitespaceReplaceChar': '-', // Replace spaces with replacement
'charmap': {'Å': 'A', 'Ö': 'O' ... }, // A complete replacement of the charmap. All characters not in the map will be replaced by the unidentifiedReplaceChar
'multiCharmap': = {'<3': 'love', '||': 'and'}, // These will be matched before the single chars, also a complete replacement
'removeMultipleWhitespace': = true, // Will replace all multiple whitespaces with a single one
'trim': = true, // Run trim() on the string
'unidentifiedReplaceChar': = '', // If unidentified characters are found they are replaced with this string
'whitespaces': = [' ', '\t', '\xa0'] // A list of characters identified as whitespaces
//'wordLimit': 5 // Limits the amount of words to this number (Currently not supported)
});
```
### Option modes
```javascript
slug.defaults.mode ='pretty';
slug.defaults.modes['rfc3986'] = {
'replacement': '-',
'symbols': true,
'remove': null,
'lower': true,
'charmap': slug.charmap,
'multicharmap': slug.multicharmap
};
slug.defaults.modes['pretty'] = {
'replacement': '-',
'symbols': true,
'remove': /[.]/g,
'lower': false,
'charmap': slug.charmap,
'multicharmap': slug.multicharmap
};
```
## Browser
When using browserify you might want to remove the symbols table from your bundle by using `--ignore` similar to this:
```bash
# Generates a standalone slug browser bundle:
browserify slug.js --ignore unicode/category/So -s slug > slug-browser.js
```
When using webpack you can use:
```javascript
externals: {
'unicode/category/So': '{}',
}
```
In your webpack config to replace the require with an empty object stub.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc