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

@sindresorhus/slugify

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sindresorhus/slugify - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

22

index.d.ts

@@ -115,2 +115,22 @@ export interface Options {

readonly preserveLeadingUnderscore?: boolean;
/**
If your string ends with a dash, it will be preserved in the slugified string.
For example, using slugify on an input field would allow for validation while not preventing the user from writing a slug.
@default false
@example
```
import slugify from '@sindresorhus/slugify';
slugify('foo-bar-');
//=> 'foo-bar'
slugify('foo-bar-', {preserveTrailingDash: true});
//=> 'foo-bar-'
```
*/
readonly preserveTrailingDash?: boolean;
}

@@ -167,3 +187,3 @@

/**
Returns a new instance of `slugify(string, options?)` with a counter to handle multiple occurences of the same string.
Returns a new instance of `slugify(string, options?)` with a counter to handle multiple occurrences of the same string.

@@ -170,0 +190,0 @@ @param string - String to slugify.

@@ -34,2 +34,3 @@ import escapeStringRegexp from 'escape-string-regexp';

preserveLeadingUnderscore: false,
preserveTrailingDash: false,
...options

@@ -39,2 +40,3 @@ };

const shouldPrependUnderscore = options.preserveLeadingUnderscore && string.startsWith('_');
const shouldAppendDash = options.preserveTrailingDash && string.endsWith('-');

@@ -69,2 +71,6 @@ const customReplacements = new Map([

if (shouldAppendDash) {
string = `${string}-`;
}
return string;

@@ -71,0 +77,0 @@ }

2

package.json
{
"name": "@sindresorhus/slugify",
"version": "2.0.0",
"version": "2.1.0",
"description": "Slugify a string",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -170,5 +170,24 @@ # slugify

##### preserveTrailingDash
Type: `boolean`\
Default: `false`
If your string ends with a dash, it will be preserved in the slugified string.
For example, using slugify on an input field would allow for validation while not preventing the user from writing a slug.
```js
import slugify from '@sindresorhus/slugify';
slugify('foo-bar-');
//=> 'foo-bar'
slugify('foo-bar-', {preserveTrailingDash: true});
//=> 'foo-bar-'
```
### slugifyWithCounter()
Returns a new instance of `slugify(string, options?)` with a counter to handle multiple occurences of the same string.
Returns a new instance of `slugify(string, options?)` with a counter to handle multiple occurrences of the same string.

@@ -175,0 +194,0 @@ #### Example

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