converter/app/converter/htmlentitiesencoder.ts

20 lines
449 B
TypeScript
Raw Normal View History

import {Converter} from "./converter";
export class HTMLEntitiesEncoder implements Converter {
getDisplayname():string {
return "Encode HTML entities";
}
getId():string {
return "encodehtmlentities";
}
convert(input:string):string {
return input
.replace(/\&/g, "&")
.replace(/\</g, "&lt;")
.replace(/\>/g, "&gt;")
.replace(/\"/g, "&quot;");
}
}