11 lines
257 B
JavaScript
11 lines
257 B
JavaScript
export function escapeChar(c) {
|
|
if (c === "&") return "&";
|
|
if (c === "<") return "<";
|
|
if (c === ">") return ">";
|
|
return c;
|
|
}
|
|
|
|
export function escapeHtml(s) {
|
|
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
}
|