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

larvitslugify

Package Overview
Dependencies
Maintainers
3
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

larvitslugify

Slugify string to make them url safe and more

  • 0.11.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
137
decreased by-8.05%
Maintainers
3
Weekly downloads
 
Created
Source

Build Status

larvitslugify

Make strings url-safe.

Vanilla javascript, no production dependencies.

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.

npm install larvitslugify

Examples

const	slug	= require('larvitslugify');

slug('i ♥ unicode');	// > i-love-unicode
slug('unicode ♥ is ☢');	// > unicode-love-is-radioactive

// If you prefer something else then `-` as seperator
slug('i ♥ unicode', '_'); // > 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('i <3 unicode');	// > i-love-unicode

Options

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

All options

slug('string', {
	'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
	'save':	= undefined	// Adds a character to the charmap to "save" from being changed or removed. Takes a string of one character or an array of single caracter strings

	//'wordLimit':	5	// Limits the amount of words to this number (Currently not supported)
});

Keywords

FAQs

Package last updated on 21 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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