Skip to content

Commit

Permalink
Fix zoneIndex parsing for IPv4-mapped IPv6 addresses
Browse files Browse the repository at this point in the history
Fixes #79
  • Loading branch information
JamesMGreene authored and whitequark committed Aug 22, 2017
1 parent a54eceb commit 6cb4089
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ipaddr.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions lib/ipaddr.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,12 @@
};

ipaddr.IPv6.parser = function(string) {
var addr, k, len, match, octet, octets;
var addr, k, len, match, octet, octets, zoneId;
if (ipv6Regexes['native'].test(string)) {
return expandIPv6(string, 8);
} else if (match = string.match(ipv6Regexes['transitional'])) {
addr = expandIPv6(match[1].slice(0, -1), 6);
zoneId = match[6] || '';
addr = expandIPv6(match[1].slice(0, -1) + zoneId, 6);
if (addr.parts) {
octets = [parseInt(match[2]), parseInt(match[3]), parseInt(match[4]), parseInt(match[5])];
for (k = 0, len = octets.length; k < len; k++) {
Expand Down
Loading

0 comments on commit 6cb4089

Please sign in to comment.