Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
16 lines (14 sloc) 383 Bytes
import { Pipe, PipeTransform } from '@angular/core';
import { isString } from '../helpers/helpers';
@Pipe({ name: 'slugify' })
export class SlugifyPipe implements PipeTransform {
transform(str: string): string {
return isString(str)
? str
.toLowerCase()
.trim()
.replace(/[^\w\-]+/g, ' ')
.replace(/\s+/g, '-')
: str;
}
}
You can’t perform that action at this time.