Improve MineGeo exploration and mapping features

This commit is contained in:
2026-10-05 13:41:36 +05:00
parent aec0641f87
commit c5368fa8cc
69 changed files with 3581 additions and 333 deletions

View File

@@ -0,0 +1,43 @@
import { test } from "node:test";
import assert from "node:assert/strict";
import { normalizeServerAddress } from "../shared/server-address";
test("Minecraft addresses compare case, trailing DNS dot and default port consistently", () => {
for (const value of [
"play.example.com",
" PLAY.EXAMPLE.COM.:25565 ",
"play.example.com:25565",
])
assert.equal(normalizeServerAddress(value), "play.example.com");
assert.equal(
normalizeServerAddress("192.168.0.120:25566"),
"192.168.0.120:25566",
);
assert.equal(normalizeServerAddress("[2001:DB8::1]:25565"), "[2001:db8::1]");
assert.equal(normalizeServerAddress("[::1]:25566"), "[::1]:25566");
assert.equal(
normalizeServerAddress("play.example.com:00080"),
"play.example.com:80",
);
});
test("clearing the server address disables its check", () => {
for (const value of [null, undefined, "", " "])
assert.equal(normalizeServerAddress(value), null);
});
test("addresses reject URLs, paths, credentials, invalid hosts and ports", () => {
for (const value of [
"https://play.example.com",
"player@host",
"host/path",
"host?query",
"host:0",
"host:65536",
"host:abcdef",
"a..b",
"-host",
"host-",
"[abc]",
"[:::]",
"a".repeat(64),
])
assert.throws(() => normalizeServerAddress(value), value);
});