Skip to content
A string slugifier
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig
.eslintrc.json
.travis.yml
LICENSE
README.md
_test.ts
mod.ts
mod_test.ts
tsconfig.json

README.md

Deno Slugify Build Status

A string slugifier

import { slugify } from "./mod.ts";

slugify('some string') // some-string

// if you prefer something other than '-' as separator
slugify('some string', '_')  // some_string

Options

slugify('some string', {
  replacement: '-',    // replace spaces with replacement
  remove: null,        // regex to remove characters
  lower: true          // result in lower case
})

Extend

Out of the box slugify comes with support for a handful of Unicode symbols. For example the (radioactive) symbol is not defined in the charMap object in [index.js][index] and therefore it will be stripped by default:

slugify('unicode ♥ is ☢') // unicode-love-is

However you can extend the supported symbols, or override the existing ones with your own:

slugify.extend({'': 'radioactive'})
slugify('unicode ♥ is ☢') // unicode-love-is-radioactive

Keep in mind that the extend method extends/overrides the default charMap for the entire process.

You can’t perform that action at this time.