frontend: deep-link via ?instance=; client/frontend default to :9090; Makefile help; v1.1.0
- cmd/frontend/web: honour ?instance=<hostname> query parameter on the initial scope hydration so /view/?instance=lb-ams opens the dashboard scoped to that maglevd. The cookie is updated on consumption; an unknown name still falls back to the first server via App.tsx. - cmd/client, cmd/frontend: --server now accepts bare hostnames. A new internal/netutil.EnsurePort canonicalises addresses by appending :9090 when no port is given, with bracketing for bare IPv6 literals. Unit test covers the IPv4/IPv6/bracketed/already-ported permutations. - Makefile: new self-documenting `help` target as the default rule; every user-facing target now carries a `## ` description that the awk-based help auto-extracts. fixstyle-web skips with a friendly message when prettier isn't installed instead of failing on npx. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package netutil
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestEnsurePort(t *testing.T) {
|
||||
const dp = "9090"
|
||||
cases := []struct {
|
||||
in, want string
|
||||
}{
|
||||
{"", ""},
|
||||
{"chbtl2", "chbtl2:9090"},
|
||||
{"chbtl2:9090", "chbtl2:9090"},
|
||||
{"chbtl2:1234", "chbtl2:1234"},
|
||||
{"lb-ams.example.com", "lb-ams.example.com:9090"},
|
||||
{"lb-ams.example.com:9090", "lb-ams.example.com:9090"},
|
||||
{"192.0.2.1", "192.0.2.1:9090"},
|
||||
{"192.0.2.1:9090", "192.0.2.1:9090"},
|
||||
{"::1", "[::1]:9090"},
|
||||
{"2001:db8::1", "[2001:db8::1]:9090"},
|
||||
{"[::1]:9090", "[::1]:9090"},
|
||||
{"[2001:db8::1]:443", "[2001:db8::1]:443"},
|
||||
// Already-bracketed but missing port: net.SplitHostPort rejects
|
||||
// it, ParseIP rejects the bracketed textual form, so the plain
|
||||
// concat path adds ":9090" and yields a valid host:port.
|
||||
{"[::1]", "[::1]:9090"},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
got := EnsurePort(tc.in, dp)
|
||||
if got != tc.want {
|
||||
t.Errorf("EnsurePort(%q) = %q, want %q", tc.in, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user