MCPcopy Create free account
hub / github.com/bywwcnll/StreamPanel / decodeEscapedText

Function decodeEscapedText

devtools/panel.bundle.js:2060–2085  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

2058 }
2059
2060 function decodeEscapedText(text) {
2061 if (!text) return '';
2062
2063 const trimmed = text.trim();
2064 if (trimmed.length >= 2 && trimmed.startsWith('"') && trimmed.endsWith('"')) {
2065 try {
2066 return JSON.parse(trimmed);
2067 } catch (error) {
2068 // Fall back to tolerant decoding below.
2069 }
2070 }
2071
2072 return text
2073 .replace(/\\u\{([0-9a-fA-F]+)\}/g, (_, hex) => {
2074 const codePoint = parseInt(hex, 16);
2075 return Number.isFinite(codePoint) ? String.fromCodePoint(codePoint) : _;
2076 })
2077 .replace(/\\u([0-9a-fA-F]{4})/g, (_, hex) => String.fromCharCode(parseInt(hex, 16)))
2078 .replace(/\\x([0-9a-fA-F]{2})/g, (_, hex) => String.fromCharCode(parseInt(hex, 16)))
2079 .replace(/\\n/g, '\n')
2080 .replace(/\\r/g, '\r')
2081 .replace(/\\t/g, '\t')
2082 .replace(/\\"/g, '"')
2083 .replace(/\\'/g, "'")
2084 .replace(/\\\\/g, '\\');
2085 }
2086
2087 function setupModalClickHandlers() {
2088 elements$2.presetModal.addEventListener('click', (e) => {

Callers 1

updateTextDecodeOutputFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected