Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

slug-component

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slug-component - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

2

component.json

@@ -5,3 +5,3 @@ {

"description": "slug generator",
"version": "1.0.0",
"version": "1.1.0",
"keywords": ["slug"],

@@ -8,0 +8,0 @@ "dependencies": {},

1.1.0 / 2013-02-15
==================
* added options object, with replace and separator [ianstormtaylor]
0.0.1 / 2012-11-28

@@ -3,0 +8,0 @@ ==================

@@ -11,11 +11,14 @@

* @param {String} str
* @param {String} repl defaulted to `-`
* @param {Object} options
* @config {String|RegExp} [replace] characters to replace, defaulted to `/[^a-z0-9]/g`
* @config {String} [separator] separator to insert, defaulted to `-`
* @return {String}
*/
module.exports = function (str, repl) {
module.exports = function (str, options) {
options || (options = {});
return str.toLowerCase()
.replace(/[^a-z0-9]/g, ' ')
.replace(options.replace || /[^a-z0-9]/g, ' ')
.replace(/^ +| +$/g, '')
.replace(/ +/g, repl || '-')
.replace(/ +/g, options.separator || '-')
};
{
"name": "slug-component",
"description": "slug generator",
"version": "1.0.0",
"version": "1.1.0",
"author": "Amir Abu Shareb <yields@icloud.com>",
"license": "MIT"
}

@@ -27,6 +27,10 @@

it('should respect `replacement` parameter', function () {
assert(gen('foo bar', '_') == 'foo_bar');
it('should respect `separator` option', function () {
assert(gen('foo bar', { separator: '_' }) == 'foo_bar');
})
it('should respect `replace` option', function () {
assert(gen('foo bar', { replace : /o/g }) == 'f-bar');
})
it('should trim', function () {

@@ -33,0 +37,0 @@ assert(gen(' foo ---') == 'foo');

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