Re: [whatwg/url] Annevk/ipv6 more (#286)

For me it's a bit confusing that **IPv6 parser's** variable <var>piece</var> actually stores not piece's value, but piece's index, while similar variable <var>ipv4Piece</var> stores value. So maybe rename it to more clear <var>pieceIndex</var>; e.g.: `address[pieceIndex]`.

Also I see some confusion in **IPv6 serializer**: the <var>piece</var> means piece's value in 5, 5.1, 5.4 steps, but the same variable is used as index in 5.3, 5.3.1, 5.5.

So I suggest to rewrite some **IPv6 serializer** steps as follows (changes are marked):

...
2. Let compress be <del>a pointer to</del><ins>an index of</ins> the first IPv6 piece in the first longest sequences of address’s IPv6 pieces that are 0.
...
5. For each <del>piece in address’s IPv6 pieces</del><ins>pieceIndex in the range 0 to 7, inclusive</ins>:
 1. If ignore0 is true and <del>piece</del><ins>address[pieceIndex]</ins> is 0, then continue.
 2. Otherwise, if ignore0 is true, set ignore0 to false.
 3. If compress <del>points to piece</del><ins>is equal to pieceIndex</ins>, then:
    1. Let separator be "::" if <ins>pieceIndex is 0 (</ins><del>piece is </del>address’s first IPv6 piece<ins>)</ins>, and U+003A (:) otherwise.
    2. Append separator to output.
    3. Set ignore0 to true and continue.
 4. Append <del>piece</del><ins>address[pieceIndex]</ins>, represented as the shortest possible lowercase hexadecimal number, to output.
  5. If <ins>pieceIndex is not 7 (</ins><del>address[piece] is not </del>address’s last IPv6 piece<ins>)</ins>, then append U+003A (:) to output.

...

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/pull/286#issuecomment-296665061

Received on Monday, 24 April 2017 13:21:05 UTC