| 3195 | // and alphanumeric chars is percent-encoded. |
| 3196 | // |
| 3197 | function 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 |