str_slug 0.1.0

Generate a URL friendly slug from the given string
Documentation

Generate a URL friendly 'slug' from the given string

str_slug generates url friendly slug from the given string.

Features

  • full unicode support.
  • ability to append/prepend a hash of the given value to the generated slug.

Options

pub struct StrSlug {
    pub use_hash: bool,
    pub use_full_hash: bool,
    pub append_hash: bool,
    pub hash_len: usize,
    pub hash_separator: char,
    pub separator: char,
    pub remove_duplicate_separators: bool,
    pub trim_separator_start: bool,
    pub trim_separator_end: bool,
    pub trim_separator_both: bool,
}

Usage

let sentence = "quick brown fox jumps over the lazy dog";
let slug = str_slug::slug(sentence);

// quick-brown-fox-jumps-over-the-lazy-dog

with a hash

let sentence = "quick brown fox jumps over the lazy dog";
let slug = str_slug::slug_hash(sentence);

// quick-brown-fox-jumps-over-the-lazy-dog_ce2907