@giladrozmarin/slugger

    1.2.0 • Public • Published

    slugger

    Slugger is a npm library that dead simple slugification for node and browser.

    What it does:

    Converts any string into a url friendly version:

    slugger('Hello yOu CRAZY Swede!'); // returns 'hello-you-crazy-swede'
    
    // optionally maintain case
    slugger('Hello yOu CRAZY Swede!', {maintainCase: true}); // returns 'Hello-yOu-CRAZY-Swede'
    
    // optionally use a different replacement character
    slugger('Hello yOu CRAZY Swede!', {replacement: '_'}); // returns 'hello_you_crazy_swede'
    
    // optionally trim to max length while not breaking any words
    slugger('Hello yOu CRAZY Swede!', {smartTrim: 9}); // returns 'hello-you'
    
    // optionally allow additional characters
    // just pass string of characters that would normally be removed
    // that you want to allow.
    slugger('Hello yOu CRAZY Swede!', {alsoAllow: "!&"}); // returns 'hello-you-crazy-swede!'
    
    // decodes URI components by default, so {decode: true} is not required
    slugger('boo%20boo') // returns 'boo-boo';
    // now without decode
    slugger('boo%20boo', {decode: false}) // returns boo20boo;

    Installing

     npm i @giladrozmarin/slugger
    

    Keywords

    none

    Install

    npm i @giladrozmarin/slugger

    DownloadsWeekly Downloads

    4

    Version

    1.2.0

    License

    ISC

    Unpacked Size

    1.99 kB

    Total Files

    4

    Last publish

    Collaborators

    • giladrozmarin