mirror of
https://github.com/gravitational/teleport
synced 2024-10-21 17:53:28 +00:00
6af6e7f566
* Vendor slack plugin and supporting libraries
* Fix up plugin integration tests (wip)
* Run GCI on vendored code
* Use newtype instead of type alias
golangci-lint currently panics on this,
"skip-files" et al don't help, as it is a linter panic, not an error
See d717045480
* Remove long-runing plugins tests from difftest
* Move access plugin tests to unit-tests-integrations
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
// Copyright 2023 Gravitational, Inc
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package lib
|
|
|
|
import (
|
|
"net/url"
|
|
"strings"
|
|
|
|
"github.com/gravitational/trace"
|
|
)
|
|
|
|
func AddrToURL(addr string) (*url.URL, error) {
|
|
var (
|
|
result *url.URL
|
|
err error
|
|
)
|
|
if !strings.HasPrefix(addr, "http://") && !strings.HasPrefix(addr, "https://") {
|
|
addr = "https://" + addr
|
|
}
|
|
if result, err = url.Parse(addr); err != nil {
|
|
return nil, trace.Wrap(err)
|
|
}
|
|
if result.Scheme == "https" && result.Port() == "443" {
|
|
// Cut off redundant :443
|
|
result.Host = result.Hostname()
|
|
}
|
|
return result, nil
|
|
}
|