converter/src/app/converter/htmlentitiesdecoder.ts

20 lines
410 B
TypeScript
Raw Normal View History

2017-04-15 19:04:49 +02:00
import {Converter} from './converter';
export class HTMLEntitiesDecoder implements Converter {
getDisplayname(): string {
2017-04-15 19:04:49 +02:00
return 'Decode HTML entities';
}
getId(): string {
2017-04-15 19:04:49 +02:00
return 'decodehtmlentities';
}
convert(input: string): string {
return input
2017-04-15 19:04:49 +02:00
.replace(/\&quot\;/g, '\'')
.replace(/\&gt\;/g, '>')
.replace(/\&lt\;/g, '<')
.replace(/\&amp\;/g, '&');
}
}