fix: accept bare Pi-hole IPv4 addresses

This commit is contained in:
admin committed 2026-08-14 23:38:49 +02:00
1 parent 42fa6efc84
commit 2082b68794
5 files changed
+15 -7

No files matched your search

+4
View File
@@ -101,6 +101,10 @@ func TestNewValidatesAndNormalizesPiHoleURL(t *testing.T) {
if err != nil || client.BaseURL() != "http://pihole.local/custom/api" {
t.Fatalf("custom path not normalized: %q err=%v", client.BaseURL(), err)
}
client, err = New("10.0.20.100", false)
if err != nil || client.BaseURL() != "http://10.0.20.100/api" {
t.Fatalf("bare IPv4 address not normalized: %q err=%v", client.BaseURL(), err)
}
for _, invalid := range []string{"pi.hole", "ftp://pi.hole", "https://user:pass@pi.hole", "https://pi.hole?sid=secret"} {
if _, err := New(invalid, false); err == nil {
t.Errorf("invalid URL accepted: %s", invalid)