2.0.0 • Published 3 years ago

is-slug v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

is-slug

Check if a string is in slug form.

Installation

npm:

npm install --save-dev is-slug

yarn:

yarn add -D is-slug

Usage

import isSlug from 'is-slug';

isSlug('hello-world'); // true
isSlug('hello_world', { separator: '_' }); // true
isSlug('-hello-world'); // false
isSlug('hello-world-'); // false
isSlug('hello--world'); // false

isSlug('hello'); // true
isSlug('hello, world'); // false
isSlug('hello-world, how are you?'); // false

isSlug('1-2-3', { charset: /[a-z]/ }); // false
isSlug('A-B-C', { charset: /[a-z]/ }); // false
isSlug('abc-def-xyz', { charset: /[a-z]/ }); // true

API

isSlug(string, options?)

optiontypedescriptiondefault
separatorstringThe symbol used to separate parts of a slugged string.-
charsetRegExpA regex character set or pattern to match non-separating characters in the string./[a-zA-Z0-9]/
2.0.0

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago