MCPcopy Create free account
hub / github.com/witheve/Eve / getEncodeCache

Function getEncodeCache

src/commonmark.js:3197–3219  ·  view source on GitHub ↗
(exclude)

Source from the content-addressed store, hash-verified

3195// and alphanumeric chars is percent-encoded.
3196//
3197function getEncodeCache(exclude) {
3198 var i, ch, cache = encodeCache[exclude];
3199 if (cache) { return cache; }
3200
3201 cache = encodeCache[exclude] = [];
3202
3203 for (i = 0; i < 128; i++) {
3204 ch = String.fromCharCode(i);
3205
3206 if (/^[0-9a-z]$/i.test(ch)) {
3207 // always allow unencoded alphanumeric characters
3208 cache.push(ch);
3209 } else {
3210 cache.push('%' + ('0' + i.toString(16).toUpperCase()).slice(-2));
3211 }
3212 }
3213
3214 for (i = 0; i < exclude.length; i++) {
3215 cache[exclude.charCodeAt(i)] = exclude[i];
3216 }
3217
3218 return cache;
3219}
3220
3221
3222// Encode unsafe characters with percent-encoding, skipping already

Callers 1

encodeFunction · 0.85

Calls 1

testMethod · 0.45

Tested by

no test coverage detected