MCPcopy
hub / github.com/di-sukharev/opencommit / parseIPv6

Function parseIPv6

out/cli.cjs:3730–3834  ·  view source on GitHub ↗
(input)

Source from the content-addressed store, hash-verified

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) {

Callers 1

parseHostFunction · 0.85

Calls 3

p4Function · 0.85
at2Function · 0.85
fromMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…