(input)
| 3532 | function isHexCharByte(byte) { |
| 3533 | return byte >= 48 && byte <= 57 || byte >= 65 && byte <= 70 || byte >= 97 && byte <= 102; |
| 3534 | } |
| 3535 | function hexByteToNumber(byte) { |
| 3536 | return ( |
| 3537 | // 0-9 |
| 3538 | byte >= 48 && byte <= 57 ? byte - 48 : (byte & 223) - 55 |
| 3539 | ); |
| 3540 | } |
| 3541 | function percentDecode(input) { |
| 3542 | const length = input.length; |
| 3543 | const output = new Uint8Array(length); |
| 3544 | let j = 0; |
| 3545 | for (let i = 0; i < length; ++i) { |
| 3546 | const byte = input[i]; |
| 3547 | if (byte !== 37) { |
| 3548 | output[j++] = byte; |
| 3549 | } else if (byte === 37 && !(isHexCharByte(input[i + 1]) && isHexCharByte(input[i + 2]))) { |
| 3550 | output[j++] = 37; |
| 3551 | } else { |
| 3552 | output[j++] = hexByteToNumber(input[i + 1]) << 4 | hexByteToNumber(input[i + 2]); |
| 3553 | i += 2; |
no test coverage detected