]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blob - vendor/github.com/aws/aws-sdk-go/aws/url_1_7.go
Initial transfer of provider code
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / aws / aws-sdk-go / aws / url_1_7.go
1 // +build !go1.8
2
3 package aws
4
5 import (
6 "net/url"
7 "strings"
8 )
9
10 // URLHostname will extract the Hostname without port from the URL value.
11 //
12 // Copy of Go 1.8's net/url#URL.Hostname functionality.
13 func URLHostname(url *url.URL) string {
14 return stripPort(url.Host)
15
16 }
17
18 // stripPort is copy of Go 1.8 url#URL.Hostname functionality.
19 // https://golang.org/src/net/url/url.go
20 func stripPort(hostport string) string {
21 colon := strings.IndexByte(hostport, ':')
22 if colon == -1 {
23 return hostport
24 }
25 if i := strings.IndexByte(hostport, ']'); i != -1 {
26 return strings.TrimPrefix(hostport[:i], "[")
27 }
28 return hostport[:colon]
29 }