Skip to content

Replace any special characters in a string with an ASCII approximation.

License

Notifications You must be signed in to change notification settings

frederfred/parameterize-string

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Parameterize string

Replace any special characters in a string with an ASCII approximation. Usefull for creating URL-friendly slugs.

This package is very similar to the ActiveSupport::Inflector parameterize method in Ruby on Rails.

Installation

npm install --save parameterize-string

Usage

Default options

{
  separator: '-',
  preserveCase: false,
}

Example

import parameterize from 'parameterize-string';

parameterize('Björk Guðmundsdóttir'); // bjork-gudmundsdottir
parameterize('Björk Guðmundsdóttir', { preserveCase: true }); // Bjork-Gudmundsdottir
parameterize('Björk Guðmundsdóttir', { separator: '_' }); // bjork_gudmundsdottir

Test

npm test

About

Replace any special characters in a string with an ASCII approximation.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published