converter/src/app/converter/htmlentitiesencoder.ts

20 lines
405 B
TypeScript
Raw Normal View History

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