Skip to content

Commit

Permalink
Fix not compressing trailing zeros in IPv6
Browse files Browse the repository at this point in the history
Fixes a bug in the function findLongestZeroSequence, which ignored trailing zeros sequences.
  • Loading branch information
rmisev authored and domenic committed Jan 12, 2017
1 parent d525824 commit 787aa00
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/url-state-machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,12 @@ function findLongestZeroSequence(arr) {
}
}

// if trailing zeros
if (currLen > maxLen) {
maxIdx = currStart;
maxLen = currLen;
}

return {
idx: maxIdx,
len: maxLen
Expand Down
16 changes: 16 additions & 0 deletions test/to-upstream.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
[
"# IPv6 trailing zeros compress test",
{
"input": "http://[1:0::]",
"base": "http://example.net/",
"href": "http://[1::]/",
"origin": "http://[1::]",
"protocol": "http:",
"username": "",
"password": "",
"host": "[1::]",
"hostname": "[1::]",
"port": "",
"pathname": "/",
"search": "",
"hash": ""
}
]

0 comments on commit 787aa00

Please sign in to comment.