Skip to content

Commit f1bb61f

Browse files
authored
Merge pull request #718 from nats-io/fix-635
[FIX] identify ipv6 encoding an ipv4 as ipv6
2 parents 5c1f95f + 4df4a3e commit f1bb61f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

nats-base-client/servers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ import {
2525
} from "./core.ts";
2626

2727
export function isIPV4OrHostname(hp: string): boolean {
28-
if (hp.indexOf(".") !== -1) {
29-
return true;
30-
}
3128
if (hp.indexOf("[") !== -1 || hp.indexOf("::") !== -1) {
3229
return false;
3330
}
31+
if (hp.indexOf(".") !== -1) {
32+
return true;
33+
}
3434
// if we have a plain hostname or host:port
3535
if (hp.split(":").length <= 2) {
3636
return true;

tests/servers_test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,5 @@ Deno.test("servers - port 80", () => {
131131
Deno.test("servers - hostname only", () => {
132132
assertEquals(isIPV4OrHostname("hostname"), true);
133133
assertEquals(isIPV4OrHostname("hostname:40"), true);
134+
assertEquals(isIPV4OrHostname("::ffff:35.234.43.228"), false);
134135
});

0 commit comments

Comments
 (0)