Path: blob/master/node_modules/@hapi/hoek/lib/escapeJson.js
2593 views
'use strict';12const internals = {};345module.exports = function (input) {67if (!input) {8return '';9}1011const lessThan = 0x3C;12const greaterThan = 0x3E;13const andSymbol = 0x26;14const lineSeperator = 0x2028;1516// replace method17let charCode;18return input.replace(/[<>&\u2028\u2029]/g, (match) => {1920charCode = match.charCodeAt(0);2122if (charCode === lessThan) {23return '\\u003c';24}2526if (charCode === greaterThan) {27return '\\u003e';28}2930if (charCode === andSymbol) {31return '\\u0026';32}3334if (charCode === lineSeperator) {35return '\\u2028';36}3738return '\\u2029';39});40};414243