mirror of
https://github.com/Terncode/pixel.horse.git
synced 2026-09-24 21:55:52 +02:00
16 lines
414 B
TypeScript
16 lines
414 B
TypeScript
import { Pipe, PipeTransform } from '@angular/core';
|
|
import { transliterate } from 'transliteration';
|
|
|
|
@Pipe({
|
|
name: 'translit',
|
|
})
|
|
export class TranslitPipe implements PipeTransform {
|
|
transform(value: string) {
|
|
if (!value || /^[a-z0-9-_.,\[\]!@#$%^&*{}|\/\\ ]+$/i.test(value))
|
|
return undefined;
|
|
|
|
const translit = transliterate(value);
|
|
return translit !== value ? translit : undefined;
|
|
}
|
|
}
|