fastify / fastify/fast-uri

bug: normalizeIPv6 does not normalize correct when double colon is already added

Open
#89 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
125
Forks
70
Avg merge
2d 19h
Merged PRs (30d)
4

Description

### Prerequisites

- [X] I have written a descriptive issue title
- [X] I have searched existing issues to ensure the issue has not already been raised

### Issue

normalizeIPv6 in utils can not properly normalize IPv6 addresses. Hard to describe, so here an example:

`::0000:1` has to be normalized to `::1` but it is normalized to `:::1`
`1::1:0:0:1`has to be normalized to `1::1:0:0:1`but is normalized to `1::1:::1`

So basically in the normalizeIPv6 function we have to track if we already added the double colon, and if so, dont add again a double colon.
Also if we have added a double colon following hextets with 0 need to be written out.

In #88 I modified already the stringArrayToHexStripped I added a second parameter called keepZero. So if we already added a double colon followed by a non-zero hextet, we have to track to keep the zero and if we have following 0 hextets we have to set in stringArrayToHexStripped the parameter keepZero to true.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.