MCPcopy Create free account
hub / github.com/error311/FileRise / decodeHtmlEntities

Function decodeHtmlEntities

public/js/fileListView.js:199–228  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

197}
198
199function decodeHtmlEntities(str) {
200 if (!str) return "";
201 try {
202 const input = String(str);
203 return input.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g, (match, code) => {
204 if (!code) return match;
205 if (code[0] === '#') {
206 const isHex = code[1] === 'x' || code[1] === 'X';
207 const num = isHex ? parseInt(code.slice(2), 16) : parseInt(code.slice(1), 10);
208 if (!Number.isFinite(num)) return match;
209 try { return String.fromCodePoint(num); } catch (e) { return match; }
210 }
211 const table = {
212 amp: '&',
213 lt: '<',
214 gt: '>',
215 quot: '"',
216 apos: "'",
217 nbsp: '\u00A0',
218 colon: ':',
219 slash: '/',
220 backslash: '\\'
221 };
222 const lower = code.toLowerCase();
223 return Object.prototype.hasOwnProperty.call(table, lower) ? table[lower] : match;
224 });
225 } catch (e) {
226 return String(str);
227 }
228}
229
230function compareSemverLite(a, b) {
231 const pa = String(a || '').split('.').map(n => parseInt(n, 10) || 0);

Callers 5

fillHoverPreviewForRowFunction · 0.85
navigateToSearchResultFunction · 0.85
findRowFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected