** Copyright (C) 2001-2025 Zabbix SIA
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
func Test_removeScheme(t *testing.T) {
{"+base", args{"https://localhost"}, "https", "localhost", false},
{"+full", args{"https://www.google.com:443/path1/path2"}, "https", "www.google.com:443/path1/path2", false},
{"+no_scheme", args{"localhost"}, "", "localhost", false},
{"+no_input", args{""}, "", "", false},
{"-malformed", args{"https://https://localhost"}, "", "https://https://localhost", true},
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotScheme, gotHost, err := removeScheme(tt.args.in)
if (err != nil) != tt.wantErr {
t.Errorf("removeScheme() error = %v, wantErr %v", err, tt.wantErr)
if gotScheme != tt.wantScheme {
t.Errorf("removeScheme() gotScheme = %v, want %v", gotScheme, tt.wantScheme)
if gotHost != tt.wantHost {
t.Errorf("removeScheme() gotHost = %v, want %v", gotHost, tt.wantHost)
func Test_encloseIPv6(t *testing.T) {