MCPcopy
hub / github.com/webpack/webpack-dev-server / encode

Function encode

client-src/overlay.js:64–78  ·  view source on GitHub ↗

* @param {string} text text * @returns {string} encoded text

(text)

Source from the content-addressed store, hash-verified

62 * @returns {string} encoded text
63 */
64function encode(text) {
65 if (!text) {
66 return "";
67 }
68
69 return replaceUsingRegExp(text, /[<>'"&]/g, (input) => {
70 let result = references[/** @type {keyof typeof references} */ (input)];
71 if (!result) {
72 const code =
73 input.length > 1 ? getCodePoint(input, 0) : input.charCodeAt(0);
74 result = `&#${code};`;
75 }
76 return result;
77 });
78}
79
80/**
81 * @typedef {object} Context

Callers 1

showFunction · 0.85

Calls 1

replaceUsingRegExpFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…