Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: common/lhttp/utils.go

Issue 2227113002: Update bulidbucket client (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: add readme Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package lhttp 5 package lhttp
6 6
7 import ( 7 import (
8 "errors" 8 "errors"
9 "net/url" 9 "net/url"
10 "strings" 10 "strings"
(...skipping 21 matching lines...) Expand all
32 return "", errors.New("Only http:// or https:// scheme is accept ed.") 32 return "", errors.New("Only http:// or https:// scheme is accept ed.")
33 } 33 }
34 if u.Scheme != "https" && hostRequiresSSL(u.Host) { 34 if u.Scheme != "https" && hostRequiresSSL(u.Host) {
35 return "", errors.New("only https:// scheme is accepted for apps pot hosts, it can be omitted") 35 return "", errors.New("only https:// scheme is accepted for apps pot hosts, it can be omitted")
36 } 36 }
37 if _, err = url.Parse(s); err != nil { 37 if _, err = url.Parse(s); err != nil {
38 return "", err 38 return "", err
39 } 39 }
40 return s, nil 40 return s, nil
41 } 41 }
42
43 // IsLocalHost returns true if host is local.
44 func IsLocalHost(host string) bool {
45 switch {
46 case host == "localhost", strings.HasPrefix(host, "localhost:"):
47 case host == "127.0.0.1", strings.HasPrefix(host, "127.0.0.1:"):
48 case host == "[::1]", strings.HasPrefix(host, "[::1]:"):
Vadim Sh. 2016/08/09 19:09:24 strictly speaking 0:0:0:0:0:0:0:1 is also localhos
nodir 2016/08/09 22:56:31 Done.
49 case strings.HasPrefix(host, ":"):
50
51 default:
52 return false
53 }
54 return true
55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698