Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MR414N-ID
GitHub Repository: MR414N-ID/botku2
Path: blob/master/node_modules/@hapi/hoek/lib/escapeJson.js
1126 views
1
'use strict';
2
3
const internals = {};
4
5
6
module.exports = function (input) {
7
8
if (!input) {
9
return '';
10
}
11
12
return input.replace(/[<>&\u2028\u2029]/g, internals.escape);
13
};
14
15
16
internals.escape = function (char) {
17
18
return internals.replacements.get(char);
19
};
20
21
22
internals.replacements = new Map([
23
['<', '\\u003c'],
24
['>', '\\u003e'],
25
['&', '\\u0026'],
26
['\u2028', '\\u2028'],
27
['\u2029', '\\u2029']
28
]);
29
30