Skip to content
/ slugger Public

๐ŸŒ The slugging library used by Darkshare to create incremental slugs.

Notifications You must be signed in to change notification settings

drksh/slugger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

25 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

A solid slugger

I've been looking for slugging libraries which are able to create incremental slugs, I couldn't find anything that satisfied my needs, therefore I had to have a go at it.

Incremental slugs

These are best known for their sort nature in URL-shorteners. Let me give you an example of how they can work

Let's say you have your own little URL-shortener, and each of the user submitted URL's have an id. Since base-10 limits you very quickly, character-wise, you might want to show id 81259151 as fUcod.

Usage

// Transform ID's to slugs.
Darkshare\Slugger::encode(1); // a
Darkshare\Slugger::encode(81259151); // fUcod

// Transform slugs to IDs.
Darkshare\Slugger::decode('a'); // 1
Darkshare\Slugger::decode('fUcod'); // 81259151

About

๐ŸŒ The slugging library used by Darkshare to create incremental slugs.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages