Skip to content

Commit

Permalink
Revert "HostAndPort fails to parse a nip host"
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Nov 15, 2023
1 parent 3dba400 commit 46ced3f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
2 changes: 1 addition & 1 deletion src/main/java/io/vertx/core/net/impl/HostAndPortImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static int parseIPv4Address(String s, int from, int to) {
return -1;
}
}
return from < to && s.charAt(from + 1) != ':' ? -1 : from;
return from;
}

static int parseDecOctet(String s, int from, int to) {
Expand Down
7 changes: 0 additions & 7 deletions src/test/java/io/vertx/core/net/impl/HostAndPortTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ public void testParseIPV4Address() {
assertEquals(7, HostAndPortImpl.parseIPv4Address("0.0.0.0", 0, 7));
assertEquals(11, HostAndPortImpl.parseIPv4Address("192.168.0.0", 0, 11));
assertEquals(-1, HostAndPortImpl.parseIPv4Address("011.168.0.0", 0, 11));
assertEquals(-1, HostAndPortImpl.parseIPv4Address("10.0.0.1.nip.io", 0, 15));
assertEquals(8, HostAndPortImpl.parseIPv4Address("10.0.0.1.nip.io", 0, 8));
}

@Test
Expand All @@ -44,22 +42,17 @@ public void testParseRegName() {
assertEquals(5, HostAndPortImpl.parseRegName("abcdef:1234", 0, 5));
assertEquals(11, HostAndPortImpl.parseRegName("example.com", 0, 11));
assertEquals(14, HostAndPortImpl.parseRegName("example-fr.com", 0, 14));
assertEquals(15, HostAndPortImpl.parseRegName("10.0.0.1.nip.io", 0, 15));
}

@Test
public void testParseHost() {
assertEquals(14, HostAndPortImpl.parseHost("example-fr.com", 0, 14));
assertEquals(5, HostAndPortImpl.parseHost("[0::]", 0, 5));
assertEquals(7, HostAndPortImpl.parseHost("0.0.0.0", 0, 7));
assertEquals(8, HostAndPortImpl.parseHost("10.0.0.1.nip.io", 0, 8));
assertEquals(15, HostAndPortImpl.parseHost("10.0.0.1.nip.io", 0, 15));
}

@Test
public void testParseHostAndPort() {
assertHostAndPort("10.0.0.1.nip.io", -1, "10.0.0.1.nip.io");
assertHostAndPort("10.0.0.1.nip.io", 8443, "10.0.0.1.nip.io:8443");
assertHostAndPort("example.com", 8080, "example.com:8080");
assertHostAndPort("example.com", -1, "example.com");
assertHostAndPort("0.1.2.3", -1, "0.1.2.3");
Expand Down

0 comments on commit 46ced3f

Please sign in to comment.