Slugifier is an object responsible for generating URL slug representation of given input. Usually it’s used to generate URL-friendly resource identifiers. To describe this feature pl.wrzasq.commons.text.slugifier.Slugifier
interface has been introduced. It declares two methods, both named slugify()
. One variant is responsible for generating output from single string and second one - from an array of strings.
The simplest implementation is provided by pl.wrzasq.commons.text.slugifier.SimpleSlugifier
. It does the following stuff:
-
by default), always single;-
characters;Here are some examples:
Initial value | Generated slug |
---|---|
FOO |
foo |
Chillout Development |
chillout-development |
Chillóut -- Devęlopment |
chillout-development |
-=[ TEST ]=- |
test |
You can change the delimiter also if you want:
import pl.wrzasq.commons.text.slugifier.SimpleSlugifier // default separator: "-" val slugifier = SimpleSlugifier() // separator of your choice val customSlugifier = SimpleSlugifier("::")