| 3728 | return output; |
| 3729 | } |
| 3730 | function parseIPv6(input) { |
| 3731 | const address = [0, 0, 0, 0, 0, 0, 0, 0]; |
| 3732 | let pieceIndex = 0; |
| 3733 | let compress = null; |
| 3734 | let pointer = 0; |
| 3735 | input = Array.from(input, (c4) => c4.codePointAt(0)); |
| 3736 | if (input[pointer] === p4(":")) { |
| 3737 | if (input[pointer + 1] !== p4(":")) { |
| 3738 | return failure; |
| 3739 | } |
| 3740 | pointer += 2; |
| 3741 | ++pieceIndex; |
| 3742 | compress = pieceIndex; |
| 3743 | } |
| 3744 | while (pointer < input.length) { |
| 3745 | if (pieceIndex === 8) { |
| 3746 | return failure; |
| 3747 | } |
| 3748 | if (input[pointer] === p4(":")) { |
| 3749 | if (compress !== null) { |
| 3750 | return failure; |
| 3751 | } |
| 3752 | ++pointer; |
| 3753 | ++pieceIndex; |
| 3754 | compress = pieceIndex; |
| 3755 | continue; |
| 3756 | } |
| 3757 | let value = 0; |
| 3758 | let length = 0; |
| 3759 | while (length < 4 && infra.isASCIIHex(input[pointer])) { |
| 3760 | value = value * 16 + parseInt(at2(input, pointer), 16); |
| 3761 | ++pointer; |
| 3762 | ++length; |
| 3763 | } |
| 3764 | if (input[pointer] === p4(".")) { |
| 3765 | if (length === 0) { |
| 3766 | return failure; |
| 3767 | } |
| 3768 | pointer -= length; |
| 3769 | if (pieceIndex > 6) { |
| 3770 | return failure; |
| 3771 | } |
| 3772 | let numbersSeen = 0; |
| 3773 | while (input[pointer] !== void 0) { |
| 3774 | let ipv4Piece = null; |
| 3775 | if (numbersSeen > 0) { |
| 3776 | if (input[pointer] === p4(".") && numbersSeen < 4) { |
| 3777 | ++pointer; |
| 3778 | } else { |
| 3779 | return failure; |
| 3780 | } |
| 3781 | } |
| 3782 | if (!infra.isASCIIDigit(input[pointer])) { |
| 3783 | return failure; |
| 3784 | } |
| 3785 | while (infra.isASCIIDigit(input[pointer])) { |
| 3786 | const number = parseInt(at2(input, pointer)); |
| 3787 | if (ipv4Piece === null) { |