converter/src/app/converter/htmlentitiesencoder.ts

20 lines
405 B
TypeScript

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;");
}
}