Home > widget-integration > FilterValidationHelper > slugify
FilterValidationHelper.slugify() method
Converts a string to a URL-friendly slug.
Transforms text into a format suitable for URLs by: - Converting to lowercase - Replacing spaces with hyphens - Removing special characters - Collapsing multiple hyphens
Signature:
slugify(text: string): string;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
text |
string |
The text to slugify. Can contain any characters. |
Returns:
string
URL-friendly slug string with only lowercase letters, numbers, and hyphens
Example
Create URL slug from filter name:
const slug = this.validationHelper.slugify('Brand Name & Color');
// Returns: 'brand-name-color'
const url = `/filters/${slug}`;